{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data Mining, an introduction to the Pandas package \n",
    "This is a companion notebook for video content presented as part of the Data Mining course at SMU.\n",
    "\n",
    "In this tutorial we will be looking at a number of different parts of the Pandas package for data analysis, including:\n",
    "- Data Frames\n",
    " - loading data\n",
    " - head and tail commands\n",
    "- Munging\n",
    " - indexing operations\n",
    " - basic statistics\n",
    " - encoding\n",
    " - imputation (optional)\n",
    "- bonus: calling R with magics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Data Frames in Pandas\n",
    "Data frames in Pandas are basically like tables of data that you can do some really interesting relational database operations upon. There are many built in methods for aggregation and visualization, but we will cover those next time.+\n",
    "\n",
    "## Data Frames in R\n",
    "The data frames in Pandas were designed provide the same data manipulation functionality as data frames within R.  Once you understand the Pandas data frame, you are well on your way to understanding the R data frame.  You can check out the following website for a detailed comparison between data frames using Pandas vs. R:\n",
    "\n",
    "[Data Frames in Pandas vs. R](http://pandas.pydata.org/pandas-docs/stable/comparison_with_r.html)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First lets load a typical table of data from a csv file. You can download the file from here:\n",
    "https://archive.ics.uci.edu/ml/datasets/Heart+Disease\n",
    "\n",
    "Make sure to place it in this directory or adjust the path for the file.\n",
    "### Reading Data from CSV with Pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "site,age,is_male,chest_pain,rest_blood_press,cholesterol,high_blood_sugar,rest_ecg,max_heart_rate,exer_angina,ST_depression,Peak_ST_seg,major_vessels,thal,has_heart_disease\n",
      "cleve,63,1,1,145,233,1,2,150,0,2.3,3,0,6,0\n",
      "cleve,67,1,4,160,286,0,2,108,1,1.5,2,3,3,2\n",
      "cleve,67,1,4,120,229,0,2,129,1,2.6,2,2,7,1\n",
      "cleve,37,1,3,130,250,0,0,187,0,3.5,3,0,3,0\n"
     ]
    }
   ],
   "source": [
    "#Python\n",
    "# let's print out the first five rows inside a csv file\n",
    "\n",
    "# NOTE: you may need to change the path to the file, \n",
    "#       depending on where you saved the data\n",
    "with open('data/heart_disease.csv') as fid:\n",
    "    for idx, row in enumerate(fid):\n",
    "        print row,\n",
    "        if idx >= 4:\n",
    "            break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#Pandas\n",
    "# now let's read in the same data to save it as a dataframe\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv('data/heart_disease.csv') # read in the csv file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>site</th>\n",
       "      <th>age</th>\n",
       "      <th>is_male</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>high_blood_sugar</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>exer_angina</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 63</td>\n",
       "      <td> 1</td>\n",
       "      <td> 1</td>\n",
       "      <td> 145</td>\n",
       "      <td> 233</td>\n",
       "      <td> 1</td>\n",
       "      <td> 2</td>\n",
       "      <td> 150</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2.3</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 67</td>\n",
       "      <td> 1</td>\n",
       "      <td> 4</td>\n",
       "      <td> 160</td>\n",
       "      <td> 286</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 108</td>\n",
       "      <td> 1</td>\n",
       "      <td> 1.5</td>\n",
       "      <td> 2</td>\n",
       "      <td> 3</td>\n",
       "      <td> 3</td>\n",
       "      <td> 2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 67</td>\n",
       "      <td> 1</td>\n",
       "      <td> 4</td>\n",
       "      <td> 120</td>\n",
       "      <td> 229</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 129</td>\n",
       "      <td> 1</td>\n",
       "      <td> 2.6</td>\n",
       "      <td> 2</td>\n",
       "      <td> 2</td>\n",
       "      <td> 7</td>\n",
       "      <td> 1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 37</td>\n",
       "      <td> 1</td>\n",
       "      <td> 3</td>\n",
       "      <td> 130</td>\n",
       "      <td> 250</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 187</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3.5</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 41</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 130</td>\n",
       "      <td> 204</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 172</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1.4</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    site  age  is_male  chest_pain rest_blood_press cholesterol  \\\n",
       "0  cleve   63        1           1              145         233   \n",
       "1  cleve   67        1           4              160         286   \n",
       "2  cleve   67        1           4              120         229   \n",
       "3  cleve   37        1           3              130         250   \n",
       "4  cleve   41        0           2              130         204   \n",
       "\n",
       "  high_blood_sugar rest_ecg max_heart_rate exer_angina ST_depression  \\\n",
       "0                1        2            150           0           2.3   \n",
       "1                0        2            108           1           1.5   \n",
       "2                0        2            129           1           2.6   \n",
       "3                0        0            187           0           3.5   \n",
       "4                0        2            172           0           1.4   \n",
       "\n",
       "  Peak_ST_seg major_vessels thal  has_heart_disease  \n",
       "0           3             0    6                  0  \n",
       "1           2             3    3                  2  \n",
       "2           2             2    7                  1  \n",
       "3           3             0    3                  0  \n",
       "4           1             0    3                  0  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "# now lets look at the data\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Installing the R Kernel for use in iPython Notebook\n",
    "\n",
    "###### Using Anaconda, it is relatively simple to install the R kernel for iPython Notebook.  This is done using the following command from any console window:\n",
    "\n",
    "conda install -c r r-essentials\n",
    "\n",
    "This actually uses anaconda's r channel and searches for the package r-essentials to install.  The r-essentials package includes the IRKernel and over 80 of the most used R packages for data science, including dplyr, shiny, ggplot2, tidyr,caret, nnet, and many others!    \n",
    "\n",
    "###### To avoid naming conflicts, every R package avaiable  within Anaconda's r channel uses the same name as its corresponding R library, except prefixed with \"r-\".  For example, if you would normally access a package in R using the following library command:\n",
    "\n",
    "library(SparkR)\n",
    "\n",
    "###### You would use the following command to install this package using conda: \n",
    "\n",
    "conda install -c r r-SparkR\n",
    "\n",
    "You will see some examples of this later on!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# now let's read in the same data using R and then save it as a dataframe\n",
    "\n",
    "# set the working directory (this may come in handy sometimes when using R or R Studio)\n",
    "#setwd(\"D:\\\\SMU\\\\Larson\\DataMiningClass\\\\2U_DataMining\\\\Jakes Notebooks\\data\")  \n",
    "\n",
    "df = inputData <- read.csv(\"data/heart_disease.csv\",sep = \",\", header = T)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>site</th><th scope=col>age</th><th scope=col>is_male</th><th scope=col>chest_pain</th><th scope=col>rest_blood_press</th><th scope=col>cholesterol</th><th scope=col>high_blood_sugar</th><th scope=col>rest_ecg</th><th scope=col>max_heart_rate</th><th scope=col>exer_angina</th><th scope=col>ST_depression</th><th scope=col>Peak_ST_seg</th><th scope=col>major_vessels</th><th scope=col>thal</th><th scope=col>has_heart_disease</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>cleve</td><td>63</td><td>1</td><td>1</td><td>145</td><td>233</td><td>1</td><td>2</td><td>150</td><td>0</td><td>2.3</td><td>3</td><td>0</td><td>6</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>cleve</td><td>67</td><td>1</td><td>4</td><td>160</td><td>286</td><td>0</td><td>2</td><td>108</td><td>1</td><td>1.5</td><td>2</td><td>3</td><td>3</td><td>2</td></tr>\n",
       "\t<tr><th scope=row>3</th><td>cleve</td><td>67</td><td>1</td><td>4</td><td>120</td><td>229</td><td>0</td><td>2</td><td>129</td><td>1</td><td>2.6</td><td>2</td><td>2</td><td>7</td><td>1</td></tr>\n",
       "\t<tr><th scope=row>4</th><td>cleve</td><td>37</td><td>1</td><td>3</td><td>130</td><td>250</td><td>0</td><td>0</td><td>187</td><td>0</td><td>3.5</td><td>3</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>5</th><td>cleve</td><td>41</td><td>0</td><td>2</td><td>130</td><td>204</td><td>0</td><td>2</td><td>172</td><td>0</td><td>1.4</td><td>1</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>6</th><td>cleve</td><td>56</td><td>1</td><td>2</td><td>120</td><td>236</td><td>0</td><td>0</td><td>178</td><td>0</td><td>0.8</td><td>1</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|lllllllllllllll}\n",
       "  & site & age & is_male & chest_pain & rest_blood_press & cholesterol & high_blood_sugar & rest_ecg & max_heart_rate & exer_angina & ST_depression & Peak_ST_seg & major_vessels & thal & has_heart_disease\\\\\n",
       "\\hline\n",
       "\t1 & cleve & 63 & 1 & 1 & 145 & 233 & 1 & 2 & 150 & 0 & 2.3 & 3 & 0 & 6 & 0\\\\\n",
       "\t2 & cleve & 67 & 1 & 4 & 160 & 286 & 0 & 2 & 108 & 1 & 1.5 & 2 & 3 & 3 & 2\\\\\n",
       "\t3 & cleve & 67 & 1 & 4 & 120 & 229 & 0 & 2 & 129 & 1 & 2.6 & 2 & 2 & 7 & 1\\\\\n",
       "\t4 & cleve & 37 & 1 & 3 & 130 & 250 & 0 & 0 & 187 & 0 & 3.5 & 3 & 0 & 3 & 0\\\\\n",
       "\t5 & cleve & 41 & 0 & 2 & 130 & 204 & 0 & 2 & 172 & 0 & 1.4 & 1 & 0 & 3 & 0\\\\\n",
       "\t6 & cleve & 56 & 1 & 2 & 120 & 236 & 0 & 0 & 178 & 0 & 0.8 & 1 & 0 & 3 & 0\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "   site age is_male chest_pain rest_blood_press cholesterol high_blood_sugar\n",
       "1 cleve  63       1          1              145         233                1\n",
       "2 cleve  67       1          4              160         286                0\n",
       "3 cleve  67       1          4              120         229                0\n",
       "4 cleve  37       1          3              130         250                0\n",
       "5 cleve  41       0          2              130         204                0\n",
       "6 cleve  56       1          2              120         236                0\n",
       "  rest_ecg max_heart_rate exer_angina ST_depression Peak_ST_seg major_vessels\n",
       "1        2            150           0           2.3           3             0\n",
       "2        2            108           1           1.5           2             3\n",
       "3        2            129           1           2.6           2             2\n",
       "4        0            187           0           3.5           3             0\n",
       "5        2            172           0           1.4           1             0\n",
       "6        0            178           0           0.8           1             0\n",
       "  thal has_heart_disease\n",
       "1    6                 0\n",
       "2    3                 2\n",
       "3    7                 1\n",
       "4    3                 0\n",
       "5    3                 0\n",
       "6    3                 0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# now lets look at the data using R\n",
    "head(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 920 entries, 0 to 919\n",
      "Data columns (total 15 columns):\n",
      "site                 920 non-null object\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null int64\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     920 non-null object\n",
      "cholesterol          920 non-null object\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null object\n",
      "max_heart_rate       920 non-null object\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null object\n",
      "Peak_ST_seg          920 non-null object\n",
      "major_vessels        920 non-null object\n",
      "thal                 920 non-null object\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: int64(4), object(11)None\n"
     ]
    }
   ],
   "source": [
    "#Pandas\n",
    "# now let's a get a summary of the variables using Pandas\n",
    "print df.info()\n",
    "# we can see that most of the data \n",
    "#  is saved as an integer or as a nominal object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'data.frame':\t920 obs. of  15 variables:\n",
      " $ site             : Factor w/ 4 levels \"cleve\",\"hungary\",..: 1 1 1 1 1 1 1 1 1 1 ...\n",
      " $ age              : int  63 67 67 37 41 56 62 57 63 53 ...\n",
      " $ is_male          : int  1 1 1 1 0 1 0 0 1 1 ...\n",
      " $ chest_pain       : int  1 4 4 3 2 2 4 4 4 4 ...\n",
      " $ rest_blood_press : Factor w/ 62 levels \"?\",\"0\",\"100\",..: 36 45 18 27 27 18 33 18 27 33 ...\n",
      " $ cholesterol      : Factor w/ 218 levels \"?\",\"0\",\"100\",..: 87 140 83 104 58 90 122 193 108 57 ...\n",
      " $ high_blood_sugar : Factor w/ 3 levels \"?\",\"0\",\"1\": 3 2 2 2 2 2 2 2 2 3 ...\n",
      " $ rest_ecg         : Factor w/ 4 levels \"?\",\"0\",\"1\",\"2\": 4 4 4 2 4 2 4 2 4 4 ...\n",
      " $ max_heart_rate   : Factor w/ 120 levels \"?\",\"100\",\"102\",..: 51 9 30 87 73 79 61 64 48 56 ...\n",
      " $ exer_angina      : Factor w/ 3 levels \"?\",\"0\",\"1\": 2 3 3 2 2 2 2 3 2 3 ...\n",
      " $ ST_depression    : Factor w/ 54 levels \"-0.1\",\"-0.5\",..: 35 27 38 45 26 20 46 18 26 42 ...\n",
      " $ Peak_ST_seg      : Factor w/ 4 levels \"?\",\"1\",\"2\",\"3\": 4 3 3 4 2 2 4 2 3 4 ...\n",
      " $ major_vessels    : Factor w/ 5 levels \"?\",\"0\",\"1\",\"2\",..: 2 5 4 2 2 2 4 2 3 2 ...\n",
      " $ thal             : Factor w/ 4 levels \"?\",\"3\",\"6\",\"7\": 3 2 4 2 2 2 2 2 4 4 ...\n",
      " $ has_heart_disease: int  0 2 1 0 0 0 3 0 2 1 ...\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "      site          age           is_male         chest_pain   rest_blood_press\n",
       " cleve  :303   Min.   :28.00   Min.   :0.0000   Min.   :1.00   120    :131     \n",
       " hungary:294   1st Qu.:47.00   1st Qu.:1.0000   1st Qu.:3.00   130    :115     \n",
       " swiss  :123   Median :54.00   Median :1.0000   Median :4.00   140    :102     \n",
       " va     :200   Mean   :53.51   Mean   :0.7891   Mean   :3.25   ?      : 59     \n",
       "               3rd Qu.:60.00   3rd Qu.:1.0000   3rd Qu.:4.00   110    : 59     \n",
       "               Max.   :77.00   Max.   :1.0000   Max.   :4.00   150    : 56     \n",
       "                                                               (Other):398     \n",
       "  cholesterol  high_blood_sugar rest_ecg max_heart_rate exer_angina\n",
       " 0      :172   ?: 90            ?:  2    ?      : 55    ?: 55      \n",
       " ?      : 30   0:692            0:551    150    : 43    0:528      \n",
       " 220    : 10   1:138            1:179    140    : 41    1:337      \n",
       " 254    : 10                    2:188    120    : 35               \n",
       " 204    :  9                             130    : 30               \n",
       " 211    :  9                             160    : 26               \n",
       " (Other):680                             (Other):690               \n",
       " ST_depression Peak_ST_seg major_vessels thal    has_heart_disease\n",
       " 0      :370   ?:309       ?:611         ?:486   Min.   :0.0000   \n",
       " 1      : 83   1:203       0:181         3:196   1st Qu.:0.0000   \n",
       " 2      : 76   2:345       1: 67         6: 46   Median :1.0000   \n",
       " ?      : 62   3: 63       2: 41         7:192   Mean   :0.9957   \n",
       " 1.5    : 48               3: 20                 3rd Qu.:2.0000   \n",
       " 3      : 28                                     Max.   :4.0000   \n",
       " (Other):253                                                      "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "# now let's a get a summary of the variables using R\n",
    "str(df)\n",
    "# We can also get additional variable information using summary() \n",
    "summary(df)\n",
    "# we can see that most of the data \n",
    "#  is saved as an integer or as a factor "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This data has been read into working memory and is known as a DataFrame.\n",
    "\n",
    "### Reading Data from SQLite3 with Pandas\n",
    "We can also connect to a sqlite3 database using the built in sqlite3 package that ships with python. This data will be read into working memory and is known as a DataFrame. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>site</th>\n",
       "      <th>age</th>\n",
       "      <th>is_male</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>high_blood_sugar</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>exer_angina</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 63</td>\n",
       "      <td> 1</td>\n",
       "      <td> 1</td>\n",
       "      <td> 145</td>\n",
       "      <td> 233</td>\n",
       "      <td> 1</td>\n",
       "      <td> 2</td>\n",
       "      <td> 150</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2.3</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 67</td>\n",
       "      <td> 1</td>\n",
       "      <td> 4</td>\n",
       "      <td> 160</td>\n",
       "      <td> 286</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 108</td>\n",
       "      <td> 1</td>\n",
       "      <td> 1.5</td>\n",
       "      <td> 2</td>\n",
       "      <td> 3</td>\n",
       "      <td> 3</td>\n",
       "      <td> 2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 67</td>\n",
       "      <td> 1</td>\n",
       "      <td> 4</td>\n",
       "      <td> 120</td>\n",
       "      <td> 229</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 129</td>\n",
       "      <td> 1</td>\n",
       "      <td> 2.6</td>\n",
       "      <td> 2</td>\n",
       "      <td> 2</td>\n",
       "      <td> 7</td>\n",
       "      <td> 1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 37</td>\n",
       "      <td> 1</td>\n",
       "      <td> 3</td>\n",
       "      <td> 130</td>\n",
       "      <td> 250</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 187</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3.5</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td> cleve</td>\n",
       "      <td> 41</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 130</td>\n",
       "      <td> 204</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 172</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1.4</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    site age is_male chest_pain rest_blood_press cholesterol high_blood_sugar  \\\n",
       "0  cleve  63       1          1              145         233                1   \n",
       "1  cleve  67       1          4              160         286                0   \n",
       "2  cleve  67       1          4              120         229                0   \n",
       "3  cleve  37       1          3              130         250                0   \n",
       "4  cleve  41       0          2              130         204                0   \n",
       "\n",
       "  rest_ecg max_heart_rate exer_angina ST_depression Peak_ST_seg major_vessels  \\\n",
       "0        2            150           0           2.3           3             0   \n",
       "1        2            108           1           1.5           2             3   \n",
       "2        2            129           1           2.6           2             2   \n",
       "3        0            187           0           3.5           3             0   \n",
       "4        2            172           0           1.4           1             0   \n",
       "\n",
       "  thal has_heart_disease  \n",
       "0    6                 0  \n",
       "1    3                 2  \n",
       "2    7                 1  \n",
       "3    3                 0  \n",
       "4    3                 0  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "# but csv files are not the only thing we can work with\n",
    "# what if the data was actually in a sqlite database?\n",
    "del df\n",
    "import sqlite3\n",
    "\n",
    "con = sqlite3.connect('data/heart_disease_sql') # again this file is in the same directory\n",
    "df = pd.read_sql('SELECT * FROM heart_disease', con)  # the table name is heart_disease\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 920 entries, 0 to 919\n",
      "Data columns (total 15 columns):\n",
      "site                 920 non-null object\n",
      "age                  920 non-null object\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null object\n",
      "rest_blood_press     920 non-null object\n",
      "cholesterol          920 non-null object\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null object\n",
      "max_heart_rate       920 non-null object\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null object\n",
      "Peak_ST_seg          920 non-null object\n",
      "major_vessels        920 non-null object\n",
      "thal                 920 non-null object\n",
      "has_heart_disease    920 non-null object\n",
      "dtypes: object(15)"
     ]
    }
   ],
   "source": [
    "df.info()\n",
    "# notice now, however, that the data types are all objects!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Installing R Packages for use in R, R Studio, and iPython Notebook\n",
    "\n",
    "###### When using R or R Studio, the following commands will first install and then import any available package using R:\n",
    "\n",
    "install.packages(\"RSQLite\") # packages only need to be installed one time!\n",
    "\n",
    "library(\"RSQLite\") # the library() command imports the package from that point on. \n",
    "\n",
    "###### When using iPython Notebook however, R packages must installed in a slightly different manner.  While many packages are included with r-essentials, you will eventually run into a package such as RSQLite which is missing.  When this happens, you can install them using the following conda syntax from any command prompt:\n",
    "\n",
    "conda install -c r r-RSQLite\n",
    "\n",
    "###### Notice that \"r-\" is appended to the R package name.  Here is an example of what this would look like in windows:\n",
    "\n",
    "<img src=\"condaRpackageInstall.png\">\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### Reading Data from SQLite3 with R using the RSQLite Package\n",
    "We can also connect to a sqlite3 database using the built in RSQLite package. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>site</th><th scope=col>age</th><th scope=col>is_male</th><th scope=col>chest_pain</th><th scope=col>rest_blood_press</th><th scope=col>cholesterol</th><th scope=col>high_blood_sugar</th><th scope=col>rest_ecg</th><th scope=col>max_heart_rate</th><th scope=col>exer_angina</th><th scope=col>ST_depression</th><th scope=col>Peak_ST_seg</th><th scope=col>major_vessels</th><th scope=col>thal</th><th scope=col>has_heart_disease</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>cleve</td><td>63</td><td>1</td><td>1</td><td>145</td><td>233</td><td>1</td><td>2</td><td>150</td><td>0</td><td>2.3</td><td>3</td><td>0</td><td>6</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>cleve</td><td>67</td><td>1</td><td>4</td><td>160</td><td>286</td><td>0</td><td>2</td><td>108</td><td>1</td><td>1.5</td><td>2</td><td>3</td><td>3</td><td>2</td></tr>\n",
       "\t<tr><th scope=row>3</th><td>cleve</td><td>67</td><td>1</td><td>4</td><td>120</td><td>229</td><td>0</td><td>2</td><td>129</td><td>1</td><td>2.6</td><td>2</td><td>2</td><td>7</td><td>1</td></tr>\n",
       "\t<tr><th scope=row>4</th><td>cleve</td><td>37</td><td>1</td><td>3</td><td>130</td><td>250</td><td>0</td><td>0</td><td>187</td><td>0</td><td>3.5</td><td>3</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>5</th><td>cleve</td><td>41</td><td>0</td><td>2</td><td>130</td><td>204</td><td>0</td><td>2</td><td>172</td><td>0</td><td>1.4</td><td>1</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>6</th><td>cleve</td><td>56</td><td>1</td><td>2</td><td>120</td><td>236</td><td>0</td><td>0</td><td>178</td><td>0</td><td>0.8</td><td>1</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|lllllllllllllll}\n",
       "  & site & age & is_male & chest_pain & rest_blood_press & cholesterol & high_blood_sugar & rest_ecg & max_heart_rate & exer_angina & ST_depression & Peak_ST_seg & major_vessels & thal & has_heart_disease\\\\\n",
       "\\hline\n",
       "\t1 & cleve & 63 & 1 & 1 & 145 & 233 & 1 & 2 & 150 & 0 & 2.3 & 3 & 0 & 6 & 0\\\\\n",
       "\t2 & cleve & 67 & 1 & 4 & 160 & 286 & 0 & 2 & 108 & 1 & 1.5 & 2 & 3 & 3 & 2\\\\\n",
       "\t3 & cleve & 67 & 1 & 4 & 120 & 229 & 0 & 2 & 129 & 1 & 2.6 & 2 & 2 & 7 & 1\\\\\n",
       "\t4 & cleve & 37 & 1 & 3 & 130 & 250 & 0 & 0 & 187 & 0 & 3.5 & 3 & 0 & 3 & 0\\\\\n",
       "\t5 & cleve & 41 & 0 & 2 & 130 & 204 & 0 & 2 & 172 & 0 & 1.4 & 1 & 0 & 3 & 0\\\\\n",
       "\t6 & cleve & 56 & 1 & 2 & 120 & 236 & 0 & 0 & 178 & 0 & 0.8 & 1 & 0 & 3 & 0\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "   site age is_male chest_pain rest_blood_press cholesterol high_blood_sugar\n",
       "1 cleve  63       1          1              145         233                1\n",
       "2 cleve  67       1          4              160         286                0\n",
       "3 cleve  67       1          4              120         229                0\n",
       "4 cleve  37       1          3              130         250                0\n",
       "5 cleve  41       0          2              130         204                0\n",
       "6 cleve  56       1          2              120         236                0\n",
       "  rest_ecg max_heart_rate exer_angina ST_depression Peak_ST_seg major_vessels\n",
       "1        2            150           0           2.3           3             0\n",
       "2        2            108           1           1.5           2             3\n",
       "3        2            129           1           2.6           2             2\n",
       "4        0            187           0           3.5           3             0\n",
       "5        2            172           0           1.4           1             0\n",
       "6        0            178           0           0.8           1             0\n",
       "  thal has_heart_disease\n",
       "1    6                 0\n",
       "2    3                 2\n",
       "3    7                 1\n",
       "4    3                 0\n",
       "5    3                 0\n",
       "6    3                 0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "# but csv files are not the only thing we can work with\n",
    "# what if the data was actually in a sqlite database?\n",
    "\n",
    "#Only install one time!\n",
    "#conda install -c r r-RSQLite\n",
    "\n",
    "library(\"RSQLite\")\n",
    "\n",
    "# connect to the sqlite file\n",
    "con <- dbConnect(RSQLite::SQLite(),dbname=\"data/heart_disease_sql\")\n",
    "df <- dbGetQuery(con,'SELECT * FROM heart_disease')\n",
    "head(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'data.frame':\t920 obs. of  15 variables:\n",
      " $ site             : chr  \"cleve\" \"cleve\" \"cleve\" \"cleve\" ...\n",
      " $ age              : chr  \"63\" \"67\" \"67\" \"37\" ...\n",
      " $ is_male          : chr  \"1\" \"1\" \"1\" \"1\" ...\n",
      " $ chest_pain       : chr  \"1\" \"4\" \"4\" \"3\" ...\n",
      " $ rest_blood_press : chr  \"145\" \"160\" \"120\" \"130\" ...\n",
      " $ cholesterol      : chr  \"233\" \"286\" \"229\" \"250\" ...\n",
      " $ high_blood_sugar : chr  \"1\" \"0\" \"0\" \"0\" ...\n",
      " $ rest_ecg         : chr  \"2\" \"2\" \"2\" \"0\" ...\n",
      " $ max_heart_rate   : chr  \"150\" \"108\" \"129\" \"187\" ...\n",
      " $ exer_angina      : chr  \"0\" \"1\" \"1\" \"0\" ...\n",
      " $ ST_depression    : chr  \"2.3\" \"1.5\" \"2.6\" \"3.5\" ...\n",
      " $ Peak_ST_seg      : chr  \"3\" \"2\" \"2\" \"3\" ...\n",
      " $ major_vessels    : chr  \"0\" \"3\" \"2\" \"0\" ...\n",
      " $ thal             : chr  \"6\" \"3\" \"7\" \"3\" ...\n",
      " $ has_heart_disease: chr  \"0\" \"2\" \"1\" \"0\" ...\n"
     ]
    }
   ],
   "source": [
    "#Inspect the fields using R\n",
    "str(df)\n",
    "# notice now, however, that the data types are all chr!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " ### Working with DataFrames using Pandas and R\n",
    " We can index into a DataFrame in a number of ways:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0     63\n",
      "1     67\n",
      "2     67\n",
      "3     37\n",
      "4     41\n",
      "5     56\n",
      "6     62\n",
      "7     57\n",
      "8     63\n",
      "9     53\n",
      "10    57\n",
      "11    56\n",
      "12    56\n",
      "13    44\n",
      "14    52\n",
      "...\n",
      "905    41\n",
      "906    43\n",
      "907    44\n",
      "908    47\n",
      "909    47\n",
      "910    49\n",
      "911    49\n",
      "912    50\n",
      "913    50\n",
      "914    52\n",
      "915    52\n",
      "916    54\n",
      "917    56\n",
      "918    58\n",
      "919    65\n",
      "Name: age, Length: 920, dtype: object\n",
      "0     63\n",
      "1     67\n",
      "2     67\n",
      "3     37\n",
      "4     41\n",
      "5     56\n",
      "6     62\n",
      "7     57\n",
      "8     63\n",
      "9     53\n",
      "10    57\n",
      "11    56\n",
      "12    56\n",
      "13    44\n",
      "14    52\n",
      "...\n",
      "905    41\n",
      "906    43\n",
      "907    44\n",
      "908    47\n",
      "909    47\n",
      "910    49\n",
      "911    49\n",
      "912    50\n",
      "913    50\n",
      "914    52\n",
      "915    52\n",
      "916    54\n",
      "917    56\n",
      "918    58\n",
      "919    65\n",
      "Name: age, Length: 920, dtype: object\n"
     ]
    }
   ],
   "source": [
    "#Pandas\n",
    "# the variable names are embedded into the structure\n",
    "print df.age\n",
    "print df['age'] # but can also be accessed using strings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<ol class=list-inline>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"71\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"34\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"71\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"29\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"70\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"70\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"77\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"70\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"34\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"74\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"76\"</li>\n",
       "\t<li>\"70\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"71\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"32\"</li>\n",
       "\t<li>\"34\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"36\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"70\"</li>\n",
       "\t<li>\"70\"</li>\n",
       "\t<li>\"72\"</li>\n",
       "\t<li>\"73\"</li>\n",
       "\t<li>\"74\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"74\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"77\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"72\"</li>\n",
       "\t<li>\"75\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"75\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"72\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"74\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"76\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"70\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"71\"</li>\n",
       "\t<li>\"74\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"75\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"71\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"72\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"69\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"67\"</li>\n",
       "\t<li>\"74\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"64\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"74\"</li>\n",
       "\t<li>\"68\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"28\"</li>\n",
       "\t<li>\"29\"</li>\n",
       "\t<li>\"29\"</li>\n",
       "\t<li>\"30\"</li>\n",
       "\t<li>\"31\"</li>\n",
       "\t<li>\"32\"</li>\n",
       "\t<li>\"32\"</li>\n",
       "\t<li>\"32\"</li>\n",
       "\t<li>\"33\"</li>\n",
       "\t<li>\"34\"</li>\n",
       "\t<li>\"34\"</li>\n",
       "\t<li>\"34\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"36\"</li>\n",
       "\t<li>\"36\"</li>\n",
       "\t<li>\"36\"</li>\n",
       "\t<li>\"36\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"42\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"61\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"62\"</li>\n",
       "\t<li>\"31\"</li>\n",
       "\t<li>\"33\"</li>\n",
       "\t<li>\"34\"</li>\n",
       "\t<li>\"35\"</li>\n",
       "\t<li>\"36\"</li>\n",
       "\t<li>\"37\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"60\"</li>\n",
       "\t<li>\"63\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"32\"</li>\n",
       "\t<li>\"38\"</li>\n",
       "\t<li>\"39\"</li>\n",
       "\t<li>\"40\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"45\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"57\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"46\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"48\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"51\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"53\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"55\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"59\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "\t<li>\"66\"</li>\n",
       "\t<li>\"41\"</li>\n",
       "\t<li>\"43\"</li>\n",
       "\t<li>\"44\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"47\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"49\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"50\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"52\"</li>\n",
       "\t<li>\"54\"</li>\n",
       "\t<li>\"56\"</li>\n",
       "\t<li>\"58\"</li>\n",
       "\t<li>\"65\"</li>\n",
       "</ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item \"63\"\n",
       "\\item \"67\"\n",
       "\\item \"67\"\n",
       "\\item \"37\"\n",
       "\\item \"41\"\n",
       "\\item \"56\"\n",
       "\\item \"62\"\n",
       "\\item \"57\"\n",
       "\\item \"63\"\n",
       "\\item \"53\"\n",
       "\\item \"57\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"44\"\n",
       "\\item \"52\"\n",
       "\\item \"57\"\n",
       "\\item \"48\"\n",
       "\\item \"54\"\n",
       "\\item \"48\"\n",
       "\\item \"49\"\n",
       "\\item \"64\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"60\"\n",
       "\\item \"50\"\n",
       "\\item \"58\"\n",
       "\\item \"66\"\n",
       "\\item \"43\"\n",
       "\\item \"40\"\n",
       "\\item \"69\"\n",
       "\\item \"60\"\n",
       "\\item \"64\"\n",
       "\\item \"59\"\n",
       "\\item \"44\"\n",
       "\\item \"42\"\n",
       "\\item \"43\"\n",
       "\\item \"57\"\n",
       "\\item \"55\"\n",
       "\\item \"61\"\n",
       "\\item \"65\"\n",
       "\\item \"40\"\n",
       "\\item \"71\"\n",
       "\\item \"59\"\n",
       "\\item \"61\"\n",
       "\\item \"58\"\n",
       "\\item \"51\"\n",
       "\\item \"50\"\n",
       "\\item \"65\"\n",
       "\\item \"53\"\n",
       "\\item \"41\"\n",
       "\\item \"65\"\n",
       "\\item \"44\"\n",
       "\\item \"44\"\n",
       "\\item \"60\"\n",
       "\\item \"54\"\n",
       "\\item \"50\"\n",
       "\\item \"41\"\n",
       "\\item \"54\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"46\"\n",
       "\\item \"58\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"54\"\n",
       "\\item \"59\"\n",
       "\\item \"46\"\n",
       "\\item \"65\"\n",
       "\\item \"67\"\n",
       "\\item \"62\"\n",
       "\\item \"65\"\n",
       "\\item \"44\"\n",
       "\\item \"65\"\n",
       "\\item \"60\"\n",
       "\\item \"51\"\n",
       "\\item \"48\"\n",
       "\\item \"58\"\n",
       "\\item \"45\"\n",
       "\\item \"53\"\n",
       "\\item \"39\"\n",
       "\\item \"68\"\n",
       "\\item \"52\"\n",
       "\\item \"44\"\n",
       "\\item \"47\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"51\"\n",
       "\\item \"66\"\n",
       "\\item \"62\"\n",
       "\\item \"62\"\n",
       "\\item \"44\"\n",
       "\\item \"63\"\n",
       "\\item \"52\"\n",
       "\\item \"59\"\n",
       "\\item \"60\"\n",
       "\\item \"52\"\n",
       "\\item \"48\"\n",
       "\\item \"45\"\n",
       "\\item \"34\"\n",
       "\\item \"57\"\n",
       "\\item \"71\"\n",
       "\\item \"49\"\n",
       "\\item \"54\"\n",
       "\\item \"59\"\n",
       "\\item \"57\"\n",
       "\\item \"61\"\n",
       "\\item \"39\"\n",
       "\\item \"61\"\n",
       "\\item \"56\"\n",
       "\\item \"52\"\n",
       "\\item \"43\"\n",
       "\\item \"62\"\n",
       "\\item \"41\"\n",
       "\\item \"58\"\n",
       "\\item \"35\"\n",
       "\\item \"63\"\n",
       "\\item \"65\"\n",
       "\\item \"48\"\n",
       "\\item \"63\"\n",
       "\\item \"51\"\n",
       "\\item \"55\"\n",
       "\\item \"65\"\n",
       "\\item \"45\"\n",
       "\\item \"56\"\n",
       "\\item \"54\"\n",
       "\\item \"44\"\n",
       "\\item \"62\"\n",
       "\\item \"54\"\n",
       "\\item \"51\"\n",
       "\\item \"29\"\n",
       "\\item \"51\"\n",
       "\\item \"43\"\n",
       "\\item \"55\"\n",
       "\\item \"70\"\n",
       "\\item \"62\"\n",
       "\\item \"35\"\n",
       "\\item \"51\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"52\"\n",
       "\\item \"64\"\n",
       "\\item \"58\"\n",
       "\\item \"47\"\n",
       "\\item \"57\"\n",
       "\\item \"41\"\n",
       "\\item \"45\"\n",
       "\\item \"60\"\n",
       "\\item \"52\"\n",
       "\\item \"42\"\n",
       "\\item \"67\"\n",
       "\\item \"55\"\n",
       "\\item \"64\"\n",
       "\\item \"70\"\n",
       "\\item \"51\"\n",
       "\\item \"58\"\n",
       "\\item \"60\"\n",
       "\\item \"68\"\n",
       "\\item \"46\"\n",
       "\\item \"77\"\n",
       "\\item \"54\"\n",
       "\\item \"58\"\n",
       "\\item \"48\"\n",
       "\\item \"57\"\n",
       "\\item \"52\"\n",
       "\\item \"54\"\n",
       "\\item \"35\"\n",
       "\\item \"45\"\n",
       "\\item \"70\"\n",
       "\\item \"53\"\n",
       "\\item \"59\"\n",
       "\\item \"62\"\n",
       "\\item \"64\"\n",
       "\\item \"57\"\n",
       "\\item \"52\"\n",
       "\\item \"56\"\n",
       "\\item \"43\"\n",
       "\\item \"53\"\n",
       "\\item \"48\"\n",
       "\\item \"56\"\n",
       "\\item \"42\"\n",
       "\\item \"59\"\n",
       "\\item \"60\"\n",
       "\\item \"63\"\n",
       "\\item \"42\"\n",
       "\\item \"66\"\n",
       "\\item \"54\"\n",
       "\\item \"69\"\n",
       "\\item \"50\"\n",
       "\\item \"51\"\n",
       "\\item \"43\"\n",
       "\\item \"62\"\n",
       "\\item \"68\"\n",
       "\\item \"67\"\n",
       "\\item \"69\"\n",
       "\\item \"45\"\n",
       "\\item \"50\"\n",
       "\\item \"59\"\n",
       "\\item \"50\"\n",
       "\\item \"64\"\n",
       "\\item \"57\"\n",
       "\\item \"64\"\n",
       "\\item \"43\"\n",
       "\\item \"45\"\n",
       "\\item \"58\"\n",
       "\\item \"50\"\n",
       "\\item \"55\"\n",
       "\\item \"62\"\n",
       "\\item \"37\"\n",
       "\\item \"38\"\n",
       "\\item \"41\"\n",
       "\\item \"66\"\n",
       "\\item \"52\"\n",
       "\\item \"56\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"64\"\n",
       "\\item \"59\"\n",
       "\\item \"41\"\n",
       "\\item \"54\"\n",
       "\\item \"39\"\n",
       "\\item \"53\"\n",
       "\\item \"63\"\n",
       "\\item \"34\"\n",
       "\\item \"47\"\n",
       "\\item \"67\"\n",
       "\\item \"54\"\n",
       "\\item \"66\"\n",
       "\\item \"52\"\n",
       "\\item \"55\"\n",
       "\\item \"49\"\n",
       "\\item \"74\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"56\"\n",
       "\\item \"46\"\n",
       "\\item \"49\"\n",
       "\\item \"42\"\n",
       "\\item \"41\"\n",
       "\\item \"41\"\n",
       "\\item \"49\"\n",
       "\\item \"61\"\n",
       "\\item \"60\"\n",
       "\\item \"67\"\n",
       "\\item \"58\"\n",
       "\\item \"47\"\n",
       "\\item \"52\"\n",
       "\\item \"62\"\n",
       "\\item \"57\"\n",
       "\\item \"58\"\n",
       "\\item \"64\"\n",
       "\\item \"51\"\n",
       "\\item \"43\"\n",
       "\\item \"42\"\n",
       "\\item \"67\"\n",
       "\\item \"76\"\n",
       "\\item \"70\"\n",
       "\\item \"57\"\n",
       "\\item \"44\"\n",
       "\\item \"58\"\n",
       "\\item \"60\"\n",
       "\\item \"44\"\n",
       "\\item \"61\"\n",
       "\\item \"42\"\n",
       "\\item \"52\"\n",
       "\\item \"59\"\n",
       "\\item \"40\"\n",
       "\\item \"42\"\n",
       "\\item \"61\"\n",
       "\\item \"66\"\n",
       "\\item \"46\"\n",
       "\\item \"71\"\n",
       "\\item \"59\"\n",
       "\\item \"64\"\n",
       "\\item \"66\"\n",
       "\\item \"39\"\n",
       "\\item \"57\"\n",
       "\\item \"58\"\n",
       "\\item \"57\"\n",
       "\\item \"47\"\n",
       "\\item \"55\"\n",
       "\\item \"35\"\n",
       "\\item \"61\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"67\"\n",
       "\\item \"55\"\n",
       "\\item \"44\"\n",
       "\\item \"63\"\n",
       "\\item \"63\"\n",
       "\\item \"41\"\n",
       "\\item \"59\"\n",
       "\\item \"57\"\n",
       "\\item \"45\"\n",
       "\\item \"68\"\n",
       "\\item \"57\"\n",
       "\\item \"57\"\n",
       "\\item \"38\"\n",
       "\\item \"32\"\n",
       "\\item \"34\"\n",
       "\\item \"35\"\n",
       "\\item \"36\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"40\"\n",
       "\\item \"41\"\n",
       "\\item \"42\"\n",
       "\\item \"42\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"45\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"48\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"57\"\n",
       "\\item \"57\"\n",
       "\\item \"57\"\n",
       "\\item \"57\"\n",
       "\\item \"57\"\n",
       "\\item \"57\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"62\"\n",
       "\\item \"62\"\n",
       "\\item \"62\"\n",
       "\\item \"62\"\n",
       "\\item \"62\"\n",
       "\\item \"62\"\n",
       "\\item \"62\"\n",
       "\\item \"63\"\n",
       "\\item \"63\"\n",
       "\\item \"63\"\n",
       "\\item \"63\"\n",
       "\\item \"63\"\n",
       "\\item \"64\"\n",
       "\\item \"64\"\n",
       "\\item \"64\"\n",
       "\\item \"65\"\n",
       "\\item \"65\"\n",
       "\\item \"65\"\n",
       "\\item \"65\"\n",
       "\\item \"66\"\n",
       "\\item \"66\"\n",
       "\\item \"67\"\n",
       "\\item \"68\"\n",
       "\\item \"68\"\n",
       "\\item \"69\"\n",
       "\\item \"69\"\n",
       "\\item \"70\"\n",
       "\\item \"70\"\n",
       "\\item \"72\"\n",
       "\\item \"73\"\n",
       "\\item \"74\"\n",
       "\\item \"63\"\n",
       "\\item \"44\"\n",
       "\\item \"60\"\n",
       "\\item \"55\"\n",
       "\\item \"66\"\n",
       "\\item \"66\"\n",
       "\\item \"65\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"56\"\n",
       "\\item \"59\"\n",
       "\\item \"62\"\n",
       "\\item \"63\"\n",
       "\\item \"57\"\n",
       "\\item \"62\"\n",
       "\\item \"63\"\n",
       "\\item \"46\"\n",
       "\\item \"63\"\n",
       "\\item \"60\"\n",
       "\\item \"58\"\n",
       "\\item \"64\"\n",
       "\\item \"63\"\n",
       "\\item \"74\"\n",
       "\\item \"52\"\n",
       "\\item \"69\"\n",
       "\\item \"51\"\n",
       "\\item \"60\"\n",
       "\\item \"56\"\n",
       "\\item \"55\"\n",
       "\\item \"54\"\n",
       "\\item \"77\"\n",
       "\\item \"63\"\n",
       "\\item \"55\"\n",
       "\\item \"52\"\n",
       "\\item \"64\"\n",
       "\\item \"60\"\n",
       "\\item \"60\"\n",
       "\\item \"58\"\n",
       "\\item \"59\"\n",
       "\\item \"61\"\n",
       "\\item \"40\"\n",
       "\\item \"61\"\n",
       "\\item \"41\"\n",
       "\\item \"57\"\n",
       "\\item \"63\"\n",
       "\\item \"59\"\n",
       "\\item \"51\"\n",
       "\\item \"59\"\n",
       "\\item \"42\"\n",
       "\\item \"55\"\n",
       "\\item \"63\"\n",
       "\\item \"62\"\n",
       "\\item \"56\"\n",
       "\\item \"53\"\n",
       "\\item \"68\"\n",
       "\\item \"53\"\n",
       "\\item \"60\"\n",
       "\\item \"62\"\n",
       "\\item \"59\"\n",
       "\\item \"51\"\n",
       "\\item \"61\"\n",
       "\\item \"57\"\n",
       "\\item \"56\"\n",
       "\\item \"58\"\n",
       "\\item \"69\"\n",
       "\\item \"67\"\n",
       "\\item \"58\"\n",
       "\\item \"65\"\n",
       "\\item \"63\"\n",
       "\\item \"55\"\n",
       "\\item \"57\"\n",
       "\\item \"65\"\n",
       "\\item \"54\"\n",
       "\\item \"72\"\n",
       "\\item \"75\"\n",
       "\\item \"49\"\n",
       "\\item \"51\"\n",
       "\\item \"60\"\n",
       "\\item \"64\"\n",
       "\\item \"58\"\n",
       "\\item \"61\"\n",
       "\\item \"67\"\n",
       "\\item \"62\"\n",
       "\\item \"65\"\n",
       "\\item \"63\"\n",
       "\\item \"69\"\n",
       "\\item \"51\"\n",
       "\\item \"62\"\n",
       "\\item \"55\"\n",
       "\\item \"75\"\n",
       "\\item \"40\"\n",
       "\\item \"67\"\n",
       "\\item \"58\"\n",
       "\\item \"60\"\n",
       "\\item \"63\"\n",
       "\\item \"35\"\n",
       "\\item \"62\"\n",
       "\\item \"43\"\n",
       "\\item \"63\"\n",
       "\\item \"68\"\n",
       "\\item \"65\"\n",
       "\\item \"48\"\n",
       "\\item \"63\"\n",
       "\\item \"64\"\n",
       "\\item \"61\"\n",
       "\\item \"50\"\n",
       "\\item \"59\"\n",
       "\\item \"55\"\n",
       "\\item \"45\"\n",
       "\\item \"65\"\n",
       "\\item \"61\"\n",
       "\\item \"49\"\n",
       "\\item \"72\"\n",
       "\\item \"50\"\n",
       "\\item \"64\"\n",
       "\\item \"55\"\n",
       "\\item \"63\"\n",
       "\\item \"59\"\n",
       "\\item \"56\"\n",
       "\\item \"62\"\n",
       "\\item \"74\"\n",
       "\\item \"54\"\n",
       "\\item \"57\"\n",
       "\\item \"62\"\n",
       "\\item \"76\"\n",
       "\\item \"54\"\n",
       "\\item \"70\"\n",
       "\\item \"61\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"61\"\n",
       "\\item \"66\"\n",
       "\\item \"68\"\n",
       "\\item \"55\"\n",
       "\\item \"62\"\n",
       "\\item \"71\"\n",
       "\\item \"74\"\n",
       "\\item \"53\"\n",
       "\\item \"58\"\n",
       "\\item \"75\"\n",
       "\\item \"56\"\n",
       "\\item \"58\"\n",
       "\\item \"64\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"59\"\n",
       "\\item \"55\"\n",
       "\\item \"57\"\n",
       "\\item \"61\"\n",
       "\\item \"41\"\n",
       "\\item \"71\"\n",
       "\\item \"38\"\n",
       "\\item \"55\"\n",
       "\\item \"56\"\n",
       "\\item \"69\"\n",
       "\\item \"64\"\n",
       "\\item \"72\"\n",
       "\\item \"69\"\n",
       "\\item \"56\"\n",
       "\\item \"62\"\n",
       "\\item \"67\"\n",
       "\\item \"57\"\n",
       "\\item \"69\"\n",
       "\\item \"51\"\n",
       "\\item \"48\"\n",
       "\\item \"69\"\n",
       "\\item \"69\"\n",
       "\\item \"64\"\n",
       "\\item \"57\"\n",
       "\\item \"53\"\n",
       "\\item \"37\"\n",
       "\\item \"67\"\n",
       "\\item \"74\"\n",
       "\\item \"63\"\n",
       "\\item \"58\"\n",
       "\\item \"61\"\n",
       "\\item \"64\"\n",
       "\\item \"58\"\n",
       "\\item \"60\"\n",
       "\\item \"57\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"56\"\n",
       "\\item \"57\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"58\"\n",
       "\\item \"74\"\n",
       "\\item \"68\"\n",
       "\\item \"51\"\n",
       "\\item \"62\"\n",
       "\\item \"53\"\n",
       "\\item \"62\"\n",
       "\\item \"46\"\n",
       "\\item \"54\"\n",
       "\\item \"62\"\n",
       "\\item \"55\"\n",
       "\\item \"58\"\n",
       "\\item \"62\"\n",
       "\\item \"28\"\n",
       "\\item \"29\"\n",
       "\\item \"29\"\n",
       "\\item \"30\"\n",
       "\\item \"31\"\n",
       "\\item \"32\"\n",
       "\\item \"32\"\n",
       "\\item \"32\"\n",
       "\\item \"33\"\n",
       "\\item \"34\"\n",
       "\\item \"34\"\n",
       "\\item \"34\"\n",
       "\\item \"35\"\n",
       "\\item \"35\"\n",
       "\\item \"35\"\n",
       "\\item \"35\"\n",
       "\\item \"36\"\n",
       "\\item \"36\"\n",
       "\\item \"36\"\n",
       "\\item \"36\"\n",
       "\\item \"37\"\n",
       "\\item \"37\"\n",
       "\\item \"37\"\n",
       "\\item \"37\"\n",
       "\\item \"37\"\n",
       "\\item \"37\"\n",
       "\\item \"37\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"39\"\n",
       "\\item \"40\"\n",
       "\\item \"40\"\n",
       "\\item \"40\"\n",
       "\\item \"40\"\n",
       "\\item \"40\"\n",
       "\\item \"41\"\n",
       "\\item \"41\"\n",
       "\\item \"41\"\n",
       "\\item \"41\"\n",
       "\\item \"41\"\n",
       "\\item \"41\"\n",
       "\\item \"41\"\n",
       "\\item \"42\"\n",
       "\\item \"42\"\n",
       "\\item \"42\"\n",
       "\\item \"42\"\n",
       "\\item \"42\"\n",
       "\\item \"42\"\n",
       "\\item \"42\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"43\"\n",
       "\\item \"44\"\n",
       "\\item \"44\"\n",
       "\\item \"44\"\n",
       "\\item \"44\"\n",
       "\\item \"45\"\n",
       "\\item \"45\"\n",
       "\\item \"45\"\n",
       "\\item \"45\"\n",
       "\\item \"45\"\n",
       "\\item \"45\"\n",
       "\\item \"45\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"51\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"57\"\n",
       "\\item \"57\"\n",
       "\\item \"57\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"60\"\n",
       "\\item \"61\"\n",
       "\\item \"61\"\n",
       "\\item \"62\"\n",
       "\\item \"62\"\n",
       "\\item \"31\"\n",
       "\\item \"33\"\n",
       "\\item \"34\"\n",
       "\\item \"35\"\n",
       "\\item \"36\"\n",
       "\\item \"37\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"38\"\n",
       "\\item \"40\"\n",
       "\\item \"41\"\n",
       "\\item \"41\"\n",
       "\\item \"43\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"51\"\n",
       "\\item \"52\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"55\"\n",
       "\\item \"57\"\n",
       "\\item \"58\"\n",
       "\\item \"59\"\n",
       "\\item \"60\"\n",
       "\\item \"63\"\n",
       "\\item \"65\"\n",
       "\\item \"32\"\n",
       "\\item \"38\"\n",
       "\\item \"39\"\n",
       "\\item \"40\"\n",
       "\\item \"43\"\n",
       "\\item \"45\"\n",
       "\\item \"46\"\n",
       "\\item \"46\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"48\"\n",
       "\\item \"50\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"53\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"54\"\n",
       "\\item \"55\"\n",
       "\\item \"56\"\n",
       "\\item \"57\"\n",
       "\\item \"58\"\n",
       "\\item \"58\"\n",
       "\\item \"41\"\n",
       "\\item \"43\"\n",
       "\\item \"44\"\n",
       "\\item \"44\"\n",
       "\\item \"46\"\n",
       "\\item \"47\"\n",
       "\\item \"48\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"51\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"53\"\n",
       "\\item \"53\"\n",
       "\\item \"54\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"55\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"56\"\n",
       "\\item \"58\"\n",
       "\\item \"59\"\n",
       "\\item \"59\"\n",
       "\\item \"65\"\n",
       "\\item \"66\"\n",
       "\\item \"41\"\n",
       "\\item \"43\"\n",
       "\\item \"44\"\n",
       "\\item \"47\"\n",
       "\\item \"47\"\n",
       "\\item \"49\"\n",
       "\\item \"49\"\n",
       "\\item \"50\"\n",
       "\\item \"50\"\n",
       "\\item \"52\"\n",
       "\\item \"52\"\n",
       "\\item \"54\"\n",
       "\\item \"56\"\n",
       "\\item \"58\"\n",
       "\\item \"65\"\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. \"63\"\n",
       "2. \"67\"\n",
       "3. \"67\"\n",
       "4. \"37\"\n",
       "5. \"41\"\n",
       "6. \"56\"\n",
       "7. \"62\"\n",
       "8. \"57\"\n",
       "9. \"63\"\n",
       "10. \"53\"\n",
       "11. \"57\"\n",
       "12. \"56\"\n",
       "13. \"56\"\n",
       "14. \"44\"\n",
       "15. \"52\"\n",
       "16. \"57\"\n",
       "17. \"48\"\n",
       "18. \"54\"\n",
       "19. \"48\"\n",
       "20. \"49\"\n",
       "21. \"64\"\n",
       "22. \"58\"\n",
       "23. \"58\"\n",
       "24. \"58\"\n",
       "25. \"60\"\n",
       "26. \"50\"\n",
       "27. \"58\"\n",
       "28. \"66\"\n",
       "29. \"43\"\n",
       "30. \"40\"\n",
       "31. \"69\"\n",
       "32. \"60\"\n",
       "33. \"64\"\n",
       "34. \"59\"\n",
       "35. \"44\"\n",
       "36. \"42\"\n",
       "37. \"43\"\n",
       "38. \"57\"\n",
       "39. \"55\"\n",
       "40. \"61\"\n",
       "41. \"65\"\n",
       "42. \"40\"\n",
       "43. \"71\"\n",
       "44. \"59\"\n",
       "45. \"61\"\n",
       "46. \"58\"\n",
       "47. \"51\"\n",
       "48. \"50\"\n",
       "49. \"65\"\n",
       "50. \"53\"\n",
       "51. \"41\"\n",
       "52. \"65\"\n",
       "53. \"44\"\n",
       "54. \"44\"\n",
       "55. \"60\"\n",
       "56. \"54\"\n",
       "57. \"50\"\n",
       "58. \"41\"\n",
       "59. \"54\"\n",
       "60. \"51\"\n",
       "61. \"51\"\n",
       "62. \"46\"\n",
       "63. \"58\"\n",
       "64. \"54\"\n",
       "65. \"54\"\n",
       "66. \"60\"\n",
       "67. \"60\"\n",
       "68. \"54\"\n",
       "69. \"59\"\n",
       "70. \"46\"\n",
       "71. \"65\"\n",
       "72. \"67\"\n",
       "73. \"62\"\n",
       "74. \"65\"\n",
       "75. \"44\"\n",
       "76. \"65\"\n",
       "77. \"60\"\n",
       "78. \"51\"\n",
       "79. \"48\"\n",
       "80. \"58\"\n",
       "81. \"45\"\n",
       "82. \"53\"\n",
       "83. \"39\"\n",
       "84. \"68\"\n",
       "85. \"52\"\n",
       "86. \"44\"\n",
       "87. \"47\"\n",
       "88. \"53\"\n",
       "89. \"53\"\n",
       "90. \"51\"\n",
       "91. \"66\"\n",
       "92. \"62\"\n",
       "93. \"62\"\n",
       "94. \"44\"\n",
       "95. \"63\"\n",
       "96. \"52\"\n",
       "97. \"59\"\n",
       "98. \"60\"\n",
       "99. \"52\"\n",
       "100. \"48\"\n",
       "101. \"45\"\n",
       "102. \"34\"\n",
       "103. \"57\"\n",
       "104. \"71\"\n",
       "105. \"49\"\n",
       "106. \"54\"\n",
       "107. \"59\"\n",
       "108. \"57\"\n",
       "109. \"61\"\n",
       "110. \"39\"\n",
       "111. \"61\"\n",
       "112. \"56\"\n",
       "113. \"52\"\n",
       "114. \"43\"\n",
       "115. \"62\"\n",
       "116. \"41\"\n",
       "117. \"58\"\n",
       "118. \"35\"\n",
       "119. \"63\"\n",
       "120. \"65\"\n",
       "121. \"48\"\n",
       "122. \"63\"\n",
       "123. \"51\"\n",
       "124. \"55\"\n",
       "125. \"65\"\n",
       "126. \"45\"\n",
       "127. \"56\"\n",
       "128. \"54\"\n",
       "129. \"44\"\n",
       "130. \"62\"\n",
       "131. \"54\"\n",
       "132. \"51\"\n",
       "133. \"29\"\n",
       "134. \"51\"\n",
       "135. \"43\"\n",
       "136. \"55\"\n",
       "137. \"70\"\n",
       "138. \"62\"\n",
       "139. \"35\"\n",
       "140. \"51\"\n",
       "141. \"59\"\n",
       "142. \"59\"\n",
       "143. \"52\"\n",
       "144. \"64\"\n",
       "145. \"58\"\n",
       "146. \"47\"\n",
       "147. \"57\"\n",
       "148. \"41\"\n",
       "149. \"45\"\n",
       "150. \"60\"\n",
       "151. \"52\"\n",
       "152. \"42\"\n",
       "153. \"67\"\n",
       "154. \"55\"\n",
       "155. \"64\"\n",
       "156. \"70\"\n",
       "157. \"51\"\n",
       "158. \"58\"\n",
       "159. \"60\"\n",
       "160. \"68\"\n",
       "161. \"46\"\n",
       "162. \"77\"\n",
       "163. \"54\"\n",
       "164. \"58\"\n",
       "165. \"48\"\n",
       "166. \"57\"\n",
       "167. \"52\"\n",
       "168. \"54\"\n",
       "169. \"35\"\n",
       "170. \"45\"\n",
       "171. \"70\"\n",
       "172. \"53\"\n",
       "173. \"59\"\n",
       "174. \"62\"\n",
       "175. \"64\"\n",
       "176. \"57\"\n",
       "177. \"52\"\n",
       "178. \"56\"\n",
       "179. \"43\"\n",
       "180. \"53\"\n",
       "181. \"48\"\n",
       "182. \"56\"\n",
       "183. \"42\"\n",
       "184. \"59\"\n",
       "185. \"60\"\n",
       "186. \"63\"\n",
       "187. \"42\"\n",
       "188. \"66\"\n",
       "189. \"54\"\n",
       "190. \"69\"\n",
       "191. \"50\"\n",
       "192. \"51\"\n",
       "193. \"43\"\n",
       "194. \"62\"\n",
       "195. \"68\"\n",
       "196. \"67\"\n",
       "197. \"69\"\n",
       "198. \"45\"\n",
       "199. \"50\"\n",
       "200. \"59\"\n",
       "201. \"50\"\n",
       "202. \"64\"\n",
       "203. \"57\"\n",
       "204. \"64\"\n",
       "205. \"43\"\n",
       "206. \"45\"\n",
       "207. \"58\"\n",
       "208. \"50\"\n",
       "209. \"55\"\n",
       "210. \"62\"\n",
       "211. \"37\"\n",
       "212. \"38\"\n",
       "213. \"41\"\n",
       "214. \"66\"\n",
       "215. \"52\"\n",
       "216. \"56\"\n",
       "217. \"46\"\n",
       "218. \"46\"\n",
       "219. \"64\"\n",
       "220. \"59\"\n",
       "221. \"41\"\n",
       "222. \"54\"\n",
       "223. \"39\"\n",
       "224. \"53\"\n",
       "225. \"63\"\n",
       "226. \"34\"\n",
       "227. \"47\"\n",
       "228. \"67\"\n",
       "229. \"54\"\n",
       "230. \"66\"\n",
       "231. \"52\"\n",
       "232. \"55\"\n",
       "233. \"49\"\n",
       "234. \"74\"\n",
       "235. \"54\"\n",
       "236. \"54\"\n",
       "237. \"56\"\n",
       "238. \"46\"\n",
       "239. \"49\"\n",
       "240. \"42\"\n",
       "241. \"41\"\n",
       "242. \"41\"\n",
       "243. \"49\"\n",
       "244. \"61\"\n",
       "245. \"60\"\n",
       "246. \"67\"\n",
       "247. \"58\"\n",
       "248. \"47\"\n",
       "249. \"52\"\n",
       "250. \"62\"\n",
       "251. \"57\"\n",
       "252. \"58\"\n",
       "253. \"64\"\n",
       "254. \"51\"\n",
       "255. \"43\"\n",
       "256. \"42\"\n",
       "257. \"67\"\n",
       "258. \"76\"\n",
       "259. \"70\"\n",
       "260. \"57\"\n",
       "261. \"44\"\n",
       "262. \"58\"\n",
       "263. \"60\"\n",
       "264. \"44\"\n",
       "265. \"61\"\n",
       "266. \"42\"\n",
       "267. \"52\"\n",
       "268. \"59\"\n",
       "269. \"40\"\n",
       "270. \"42\"\n",
       "271. \"61\"\n",
       "272. \"66\"\n",
       "273. \"46\"\n",
       "274. \"71\"\n",
       "275. \"59\"\n",
       "276. \"64\"\n",
       "277. \"66\"\n",
       "278. \"39\"\n",
       "279. \"57\"\n",
       "280. \"58\"\n",
       "281. \"57\"\n",
       "282. \"47\"\n",
       "283. \"55\"\n",
       "284. \"35\"\n",
       "285. \"61\"\n",
       "286. \"58\"\n",
       "287. \"58\"\n",
       "288. \"58\"\n",
       "289. \"56\"\n",
       "290. \"56\"\n",
       "291. \"67\"\n",
       "292. \"55\"\n",
       "293. \"44\"\n",
       "294. \"63\"\n",
       "295. \"63\"\n",
       "296. \"41\"\n",
       "297. \"59\"\n",
       "298. \"57\"\n",
       "299. \"45\"\n",
       "300. \"68\"\n",
       "301. \"57\"\n",
       "302. \"57\"\n",
       "303. \"38\"\n",
       "304. \"32\"\n",
       "305. \"34\"\n",
       "306. \"35\"\n",
       "307. \"36\"\n",
       "308. \"38\"\n",
       "309. \"38\"\n",
       "310. \"38\"\n",
       "311. \"38\"\n",
       "312. \"38\"\n",
       "313. \"38\"\n",
       "314. \"40\"\n",
       "315. \"41\"\n",
       "316. \"42\"\n",
       "317. \"42\"\n",
       "318. \"43\"\n",
       "319. \"43\"\n",
       "320. \"43\"\n",
       "321. \"45\"\n",
       "322. \"46\"\n",
       "323. \"46\"\n",
       "324. \"47\"\n",
       "325. \"47\"\n",
       "326. \"47\"\n",
       "327. \"47\"\n",
       "328. \"48\"\n",
       "329. \"50\"\n",
       "330. \"50\"\n",
       "331. \"50\"\n",
       "332. \"50\"\n",
       "333. \"51\"\n",
       "334. \"51\"\n",
       "335. \"51\"\n",
       "336. \"51\"\n",
       "337. \"51\"\n",
       "338. \"51\"\n",
       "339. \"51\"\n",
       "340. \"52\"\n",
       "341. \"52\"\n",
       "342. \"52\"\n",
       "343. \"52\"\n",
       "344. \"53\"\n",
       "345. \"53\"\n",
       "346. \"53\"\n",
       "347. \"53\"\n",
       "348. \"53\"\n",
       "349. \"53\"\n",
       "350. \"53\"\n",
       "351. \"53\"\n",
       "352. \"54\"\n",
       "353. \"54\"\n",
       "354. \"54\"\n",
       "355. \"55\"\n",
       "356. \"55\"\n",
       "357. \"55\"\n",
       "358. \"55\"\n",
       "359. \"56\"\n",
       "360. \"56\"\n",
       "361. \"56\"\n",
       "362. \"56\"\n",
       "363. \"56\"\n",
       "364. \"56\"\n",
       "365. \"56\"\n",
       "366. \"56\"\n",
       "367. \"57\"\n",
       "368. \"57\"\n",
       "369. \"57\"\n",
       "370. \"57\"\n",
       "371. \"57\"\n",
       "372. \"57\"\n",
       "373. \"58\"\n",
       "374. \"58\"\n",
       "375. \"58\"\n",
       "376. \"59\"\n",
       "377. \"59\"\n",
       "378. \"59\"\n",
       "379. \"59\"\n",
       "380. \"59\"\n",
       "381. \"60\"\n",
       "382. \"60\"\n",
       "383. \"60\"\n",
       "384. \"60\"\n",
       "385. \"60\"\n",
       "386. \"60\"\n",
       "387. \"61\"\n",
       "388. \"61\"\n",
       "389. \"61\"\n",
       "390. \"61\"\n",
       "391. \"61\"\n",
       "392. \"61\"\n",
       "393. \"61\"\n",
       "394. \"61\"\n",
       "395. \"61\"\n",
       "396. \"62\"\n",
       "397. \"62\"\n",
       "398. \"62\"\n",
       "399. \"62\"\n",
       "400. \"62\"\n",
       "401. \"62\"\n",
       "402. \"62\"\n",
       "403. \"63\"\n",
       "404. \"63\"\n",
       "405. \"63\"\n",
       "406. \"63\"\n",
       "407. \"63\"\n",
       "408. \"64\"\n",
       "409. \"64\"\n",
       "410. \"64\"\n",
       "411. \"65\"\n",
       "412. \"65\"\n",
       "413. \"65\"\n",
       "414. \"65\"\n",
       "415. \"66\"\n",
       "416. \"66\"\n",
       "417. \"67\"\n",
       "418. \"68\"\n",
       "419. \"68\"\n",
       "420. \"69\"\n",
       "421. \"69\"\n",
       "422. \"70\"\n",
       "423. \"70\"\n",
       "424. \"72\"\n",
       "425. \"73\"\n",
       "426. \"74\"\n",
       "427. \"63\"\n",
       "428. \"44\"\n",
       "429. \"60\"\n",
       "430. \"55\"\n",
       "431. \"66\"\n",
       "432. \"66\"\n",
       "433. \"65\"\n",
       "434. \"60\"\n",
       "435. \"60\"\n",
       "436. \"60\"\n",
       "437. \"56\"\n",
       "438. \"59\"\n",
       "439. \"62\"\n",
       "440. \"63\"\n",
       "441. \"57\"\n",
       "442. \"62\"\n",
       "443. \"63\"\n",
       "444. \"46\"\n",
       "445. \"63\"\n",
       "446. \"60\"\n",
       "447. \"58\"\n",
       "448. \"64\"\n",
       "449. \"63\"\n",
       "450. \"74\"\n",
       "451. \"52\"\n",
       "452. \"69\"\n",
       "453. \"51\"\n",
       "454. \"60\"\n",
       "455. \"56\"\n",
       "456. \"55\"\n",
       "457. \"54\"\n",
       "458. \"77\"\n",
       "459. \"63\"\n",
       "460. \"55\"\n",
       "461. \"52\"\n",
       "462. \"64\"\n",
       "463. \"60\"\n",
       "464. \"60\"\n",
       "465. \"58\"\n",
       "466. \"59\"\n",
       "467. \"61\"\n",
       "468. \"40\"\n",
       "469. \"61\"\n",
       "470. \"41\"\n",
       "471. \"57\"\n",
       "472. \"63\"\n",
       "473. \"59\"\n",
       "474. \"51\"\n",
       "475. \"59\"\n",
       "476. \"42\"\n",
       "477. \"55\"\n",
       "478. \"63\"\n",
       "479. \"62\"\n",
       "480. \"56\"\n",
       "481. \"53\"\n",
       "482. \"68\"\n",
       "483. \"53\"\n",
       "484. \"60\"\n",
       "485. \"62\"\n",
       "486. \"59\"\n",
       "487. \"51\"\n",
       "488. \"61\"\n",
       "489. \"57\"\n",
       "490. \"56\"\n",
       "491. \"58\"\n",
       "492. \"69\"\n",
       "493. \"67\"\n",
       "494. \"58\"\n",
       "495. \"65\"\n",
       "496. \"63\"\n",
       "497. \"55\"\n",
       "498. \"57\"\n",
       "499. \"65\"\n",
       "500. \"54\"\n",
       "501. \"72\"\n",
       "502. \"75\"\n",
       "503. \"49\"\n",
       "504. \"51\"\n",
       "505. \"60\"\n",
       "506. \"64\"\n",
       "507. \"58\"\n",
       "508. \"61\"\n",
       "509. \"67\"\n",
       "510. \"62\"\n",
       "511. \"65\"\n",
       "512. \"63\"\n",
       "513. \"69\"\n",
       "514. \"51\"\n",
       "515. \"62\"\n",
       "516. \"55\"\n",
       "517. \"75\"\n",
       "518. \"40\"\n",
       "519. \"67\"\n",
       "520. \"58\"\n",
       "521. \"60\"\n",
       "522. \"63\"\n",
       "523. \"35\"\n",
       "524. \"62\"\n",
       "525. \"43\"\n",
       "526. \"63\"\n",
       "527. \"68\"\n",
       "528. \"65\"\n",
       "529. \"48\"\n",
       "530. \"63\"\n",
       "531. \"64\"\n",
       "532. \"61\"\n",
       "533. \"50\"\n",
       "534. \"59\"\n",
       "535. \"55\"\n",
       "536. \"45\"\n",
       "537. \"65\"\n",
       "538. \"61\"\n",
       "539. \"49\"\n",
       "540. \"72\"\n",
       "541. \"50\"\n",
       "542. \"64\"\n",
       "543. \"55\"\n",
       "544. \"63\"\n",
       "545. \"59\"\n",
       "546. \"56\"\n",
       "547. \"62\"\n",
       "548. \"74\"\n",
       "549. \"54\"\n",
       "550. \"57\"\n",
       "551. \"62\"\n",
       "552. \"76\"\n",
       "553. \"54\"\n",
       "554. \"70\"\n",
       "555. \"61\"\n",
       "556. \"48\"\n",
       "557. \"48\"\n",
       "558. \"61\"\n",
       "559. \"66\"\n",
       "560. \"68\"\n",
       "561. \"55\"\n",
       "562. \"62\"\n",
       "563. \"71\"\n",
       "564. \"74\"\n",
       "565. \"53\"\n",
       "566. \"58\"\n",
       "567. \"75\"\n",
       "568. \"56\"\n",
       "569. \"58\"\n",
       "570. \"64\"\n",
       "571. \"54\"\n",
       "572. \"54\"\n",
       "573. \"59\"\n",
       "574. \"55\"\n",
       "575. \"57\"\n",
       "576. \"61\"\n",
       "577. \"41\"\n",
       "578. \"71\"\n",
       "579. \"38\"\n",
       "580. \"55\"\n",
       "581. \"56\"\n",
       "582. \"69\"\n",
       "583. \"64\"\n",
       "584. \"72\"\n",
       "585. \"69\"\n",
       "586. \"56\"\n",
       "587. \"62\"\n",
       "588. \"67\"\n",
       "589. \"57\"\n",
       "590. \"69\"\n",
       "591. \"51\"\n",
       "592. \"48\"\n",
       "593. \"69\"\n",
       "594. \"69\"\n",
       "595. \"64\"\n",
       "596. \"57\"\n",
       "597. \"53\"\n",
       "598. \"37\"\n",
       "599. \"67\"\n",
       "600. \"74\"\n",
       "601. \"63\"\n",
       "602. \"58\"\n",
       "603. \"61\"\n",
       "604. \"64\"\n",
       "605. \"58\"\n",
       "606. \"60\"\n",
       "607. \"57\"\n",
       "608. \"55\"\n",
       "609. \"55\"\n",
       "610. \"56\"\n",
       "611. \"57\"\n",
       "612. \"61\"\n",
       "613. \"61\"\n",
       "614. \"58\"\n",
       "615. \"74\"\n",
       "616. \"68\"\n",
       "617. \"51\"\n",
       "618. \"62\"\n",
       "619. \"53\"\n",
       "620. \"62\"\n",
       "621. \"46\"\n",
       "622. \"54\"\n",
       "623. \"62\"\n",
       "624. \"55\"\n",
       "625. \"58\"\n",
       "626. \"62\"\n",
       "627. \"28\"\n",
       "628. \"29\"\n",
       "629. \"29\"\n",
       "630. \"30\"\n",
       "631. \"31\"\n",
       "632. \"32\"\n",
       "633. \"32\"\n",
       "634. \"32\"\n",
       "635. \"33\"\n",
       "636. \"34\"\n",
       "637. \"34\"\n",
       "638. \"34\"\n",
       "639. \"35\"\n",
       "640. \"35\"\n",
       "641. \"35\"\n",
       "642. \"35\"\n",
       "643. \"36\"\n",
       "644. \"36\"\n",
       "645. \"36\"\n",
       "646. \"36\"\n",
       "647. \"37\"\n",
       "648. \"37\"\n",
       "649. \"37\"\n",
       "650. \"37\"\n",
       "651. \"37\"\n",
       "652. \"37\"\n",
       "653. \"37\"\n",
       "654. \"38\"\n",
       "655. \"38\"\n",
       "656. \"38\"\n",
       "657. \"39\"\n",
       "658. \"39\"\n",
       "659. \"39\"\n",
       "660. \"39\"\n",
       "661. \"39\"\n",
       "662. \"39\"\n",
       "663. \"39\"\n",
       "664. \"39\"\n",
       "665. \"39\"\n",
       "666. \"39\"\n",
       "667. \"40\"\n",
       "668. \"40\"\n",
       "669. \"40\"\n",
       "670. \"40\"\n",
       "671. \"40\"\n",
       "672. \"41\"\n",
       "673. \"41\"\n",
       "674. \"41\"\n",
       "675. \"41\"\n",
       "676. \"41\"\n",
       "677. \"41\"\n",
       "678. \"41\"\n",
       "679. \"42\"\n",
       "680. \"42\"\n",
       "681. \"42\"\n",
       "682. \"42\"\n",
       "683. \"42\"\n",
       "684. \"42\"\n",
       "685. \"42\"\n",
       "686. \"43\"\n",
       "687. \"43\"\n",
       "688. \"43\"\n",
       "689. \"43\"\n",
       "690. \"43\"\n",
       "691. \"43\"\n",
       "692. \"43\"\n",
       "693. \"43\"\n",
       "694. \"44\"\n",
       "695. \"44\"\n",
       "696. \"44\"\n",
       "697. \"44\"\n",
       "698. \"45\"\n",
       "699. \"45\"\n",
       "700. \"45\"\n",
       "701. \"45\"\n",
       "702. \"45\"\n",
       "703. \"45\"\n",
       "704. \"45\"\n",
       "705. \"46\"\n",
       "706. \"46\"\n",
       "707. \"46\"\n",
       "708. \"46\"\n",
       "709. \"46\"\n",
       "710. \"46\"\n",
       "711. \"46\"\n",
       "712. \"47\"\n",
       "713. \"47\"\n",
       "714. \"47\"\n",
       "715. \"47\"\n",
       "716. \"47\"\n",
       "717. \"48\"\n",
       "718. \"48\"\n",
       "719. \"48\"\n",
       "720. \"48\"\n",
       "721. \"48\"\n",
       "722. \"48\"\n",
       "723. \"48\"\n",
       "724. \"48\"\n",
       "725. \"48\"\n",
       "726. \"48\"\n",
       "727. \"48\"\n",
       "728. \"49\"\n",
       "729. \"49\"\n",
       "730. \"49\"\n",
       "731. \"49\"\n",
       "732. \"49\"\n",
       "733. \"49\"\n",
       "734. \"49\"\n",
       "735. \"49\"\n",
       "736. \"50\"\n",
       "737. \"50\"\n",
       "738. \"50\"\n",
       "739. \"50\"\n",
       "740. \"50\"\n",
       "741. \"50\"\n",
       "742. \"50\"\n",
       "743. \"51\"\n",
       "744. \"51\"\n",
       "745. \"51\"\n",
       "746. \"51\"\n",
       "747. \"51\"\n",
       "748. \"51\"\n",
       "749. \"51\"\n",
       "750. \"52\"\n",
       "751. \"52\"\n",
       "752. \"52\"\n",
       "753. \"52\"\n",
       "754. \"52\"\n",
       "755. \"52\"\n",
       "756. \"52\"\n",
       "757. \"52\"\n",
       "758. \"53\"\n",
       "759. \"53\"\n",
       "760. \"53\"\n",
       "761. \"53\"\n",
       "762. \"53\"\n",
       "763. \"53\"\n",
       "764. \"53\"\n",
       "765. \"53\"\n",
       "766. \"53\"\n",
       "767. \"54\"\n",
       "768. \"54\"\n",
       "769. \"54\"\n",
       "770. \"54\"\n",
       "771. \"54\"\n",
       "772. \"54\"\n",
       "773. \"54\"\n",
       "774. \"54\"\n",
       "775. \"54\"\n",
       "776. \"54\"\n",
       "777. \"54\"\n",
       "778. \"54\"\n",
       "779. \"54\"\n",
       "780. \"54\"\n",
       "781. \"54\"\n",
       "782. \"54\"\n",
       "783. \"55\"\n",
       "784. \"55\"\n",
       "785. \"55\"\n",
       "786. \"55\"\n",
       "787. \"55\"\n",
       "788. \"55\"\n",
       "789. \"55\"\n",
       "790. \"55\"\n",
       "791. \"55\"\n",
       "792. \"55\"\n",
       "793. \"56\"\n",
       "794. \"56\"\n",
       "795. \"56\"\n",
       "796. \"56\"\n",
       "797. \"56\"\n",
       "798. \"57\"\n",
       "799. \"57\"\n",
       "800. \"57\"\n",
       "801. \"58\"\n",
       "802. \"58\"\n",
       "803. \"58\"\n",
       "804. \"58\"\n",
       "805. \"59\"\n",
       "806. \"59\"\n",
       "807. \"59\"\n",
       "808. \"59\"\n",
       "809. \"59\"\n",
       "810. \"60\"\n",
       "811. \"61\"\n",
       "812. \"61\"\n",
       "813. \"62\"\n",
       "814. \"62\"\n",
       "815. \"31\"\n",
       "816. \"33\"\n",
       "817. \"34\"\n",
       "818. \"35\"\n",
       "819. \"36\"\n",
       "820. \"37\"\n",
       "821. \"38\"\n",
       "822. \"38\"\n",
       "823. \"38\"\n",
       "824. \"40\"\n",
       "825. \"41\"\n",
       "826. \"41\"\n",
       "827. \"43\"\n",
       "828. \"46\"\n",
       "829. \"46\"\n",
       "830. \"46\"\n",
       "831. \"47\"\n",
       "832. \"47\"\n",
       "833. \"48\"\n",
       "834. \"48\"\n",
       "835. \"48\"\n",
       "836. \"49\"\n",
       "837. \"49\"\n",
       "838. \"49\"\n",
       "839. \"50\"\n",
       "840. \"50\"\n",
       "841. \"51\"\n",
       "842. \"52\"\n",
       "843. \"54\"\n",
       "844. \"54\"\n",
       "845. \"55\"\n",
       "846. \"57\"\n",
       "847. \"58\"\n",
       "848. \"59\"\n",
       "849. \"60\"\n",
       "850. \"63\"\n",
       "851. \"65\"\n",
       "852. \"32\"\n",
       "853. \"38\"\n",
       "854. \"39\"\n",
       "855. \"40\"\n",
       "856. \"43\"\n",
       "857. \"45\"\n",
       "858. \"46\"\n",
       "859. \"46\"\n",
       "860. \"48\"\n",
       "861. \"48\"\n",
       "862. \"48\"\n",
       "863. \"48\"\n",
       "864. \"50\"\n",
       "865. \"52\"\n",
       "866. \"52\"\n",
       "867. \"53\"\n",
       "868. \"54\"\n",
       "869. \"54\"\n",
       "870. \"54\"\n",
       "871. \"54\"\n",
       "872. \"54\"\n",
       "873. \"55\"\n",
       "874. \"56\"\n",
       "875. \"57\"\n",
       "876. \"58\"\n",
       "877. \"58\"\n",
       "878. \"41\"\n",
       "879. \"43\"\n",
       "880. \"44\"\n",
       "881. \"44\"\n",
       "882. \"46\"\n",
       "883. \"47\"\n",
       "884. \"48\"\n",
       "885. \"49\"\n",
       "886. \"49\"\n",
       "887. \"51\"\n",
       "888. \"52\"\n",
       "889. \"52\"\n",
       "890. \"52\"\n",
       "891. \"52\"\n",
       "892. \"53\"\n",
       "893. \"53\"\n",
       "894. \"54\"\n",
       "895. \"55\"\n",
       "896. \"55\"\n",
       "897. \"55\"\n",
       "898. \"56\"\n",
       "899. \"56\"\n",
       "900. \"56\"\n",
       "901. \"58\"\n",
       "902. \"59\"\n",
       "903. \"59\"\n",
       "904. \"65\"\n",
       "905. \"66\"\n",
       "906. \"41\"\n",
       "907. \"43\"\n",
       "908. \"44\"\n",
       "909. \"47\"\n",
       "910. \"47\"\n",
       "911. \"49\"\n",
       "912. \"49\"\n",
       "913. \"50\"\n",
       "914. \"50\"\n",
       "915. \"52\"\n",
       "916. \"52\"\n",
       "917. \"54\"\n",
       "918. \"56\"\n",
       "919. \"58\"\n",
       "920. \"65\"\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "  [1] \"63\" \"67\" \"67\" \"37\" \"41\" \"56\" \"62\" \"57\" \"63\" \"53\" \"57\" \"56\" \"56\" \"44\" \"52\"\n",
       " [16] \"57\" \"48\" \"54\" \"48\" \"49\" \"64\" \"58\" \"58\" \"58\" \"60\" \"50\" \"58\" \"66\" \"43\" \"40\"\n",
       " [31] \"69\" \"60\" \"64\" \"59\" \"44\" \"42\" \"43\" \"57\" \"55\" \"61\" \"65\" \"40\" \"71\" \"59\" \"61\"\n",
       " [46] \"58\" \"51\" \"50\" \"65\" \"53\" \"41\" \"65\" \"44\" \"44\" \"60\" \"54\" \"50\" \"41\" \"54\" \"51\"\n",
       " [61] \"51\" \"46\" \"58\" \"54\" \"54\" \"60\" \"60\" \"54\" \"59\" \"46\" \"65\" \"67\" \"62\" \"65\" \"44\"\n",
       " [76] \"65\" \"60\" \"51\" \"48\" \"58\" \"45\" \"53\" \"39\" \"68\" \"52\" \"44\" \"47\" \"53\" \"53\" \"51\"\n",
       " [91] \"66\" \"62\" \"62\" \"44\" \"63\" \"52\" \"59\" \"60\" \"52\" \"48\" \"45\" \"34\" \"57\" \"71\" \"49\"\n",
       "[106] \"54\" \"59\" \"57\" \"61\" \"39\" \"61\" \"56\" \"52\" \"43\" \"62\" \"41\" \"58\" \"35\" \"63\" \"65\"\n",
       "[121] \"48\" \"63\" \"51\" \"55\" \"65\" \"45\" \"56\" \"54\" \"44\" \"62\" \"54\" \"51\" \"29\" \"51\" \"43\"\n",
       "[136] \"55\" \"70\" \"62\" \"35\" \"51\" \"59\" \"59\" \"52\" \"64\" \"58\" \"47\" \"57\" \"41\" \"45\" \"60\"\n",
       "[151] \"52\" \"42\" \"67\" \"55\" \"64\" \"70\" \"51\" \"58\" \"60\" \"68\" \"46\" \"77\" \"54\" \"58\" \"48\"\n",
       "[166] \"57\" \"52\" \"54\" \"35\" \"45\" \"70\" \"53\" \"59\" \"62\" \"64\" \"57\" \"52\" \"56\" \"43\" \"53\"\n",
       "[181] \"48\" \"56\" \"42\" \"59\" \"60\" \"63\" \"42\" \"66\" \"54\" \"69\" \"50\" \"51\" \"43\" \"62\" \"68\"\n",
       "[196] \"67\" \"69\" \"45\" \"50\" \"59\" \"50\" \"64\" \"57\" \"64\" \"43\" \"45\" \"58\" \"50\" \"55\" \"62\"\n",
       "[211] \"37\" \"38\" \"41\" \"66\" \"52\" \"56\" \"46\" \"46\" \"64\" \"59\" \"41\" \"54\" \"39\" \"53\" \"63\"\n",
       "[226] \"34\" \"47\" \"67\" \"54\" \"66\" \"52\" \"55\" \"49\" \"74\" \"54\" \"54\" \"56\" \"46\" \"49\" \"42\"\n",
       "[241] \"41\" \"41\" \"49\" \"61\" \"60\" \"67\" \"58\" \"47\" \"52\" \"62\" \"57\" \"58\" \"64\" \"51\" \"43\"\n",
       "[256] \"42\" \"67\" \"76\" \"70\" \"57\" \"44\" \"58\" \"60\" \"44\" \"61\" \"42\" \"52\" \"59\" \"40\" \"42\"\n",
       "[271] \"61\" \"66\" \"46\" \"71\" \"59\" \"64\" \"66\" \"39\" \"57\" \"58\" \"57\" \"47\" \"55\" \"35\" \"61\"\n",
       "[286] \"58\" \"58\" \"58\" \"56\" \"56\" \"67\" \"55\" \"44\" \"63\" \"63\" \"41\" \"59\" \"57\" \"45\" \"68\"\n",
       "[301] \"57\" \"57\" \"38\" \"32\" \"34\" \"35\" \"36\" \"38\" \"38\" \"38\" \"38\" \"38\" \"38\" \"40\" \"41\"\n",
       "[316] \"42\" \"42\" \"43\" \"43\" \"43\" \"45\" \"46\" \"46\" \"47\" \"47\" \"47\" \"47\" \"48\" \"50\" \"50\"\n",
       "[331] \"50\" \"50\" \"51\" \"51\" \"51\" \"51\" \"51\" \"51\" \"51\" \"52\" \"52\" \"52\" \"52\" \"53\" \"53\"\n",
       "[346] \"53\" \"53\" \"53\" \"53\" \"53\" \"53\" \"54\" \"54\" \"54\" \"55\" \"55\" \"55\" \"55\" \"56\" \"56\"\n",
       "[361] \"56\" \"56\" \"56\" \"56\" \"56\" \"56\" \"57\" \"57\" \"57\" \"57\" \"57\" \"57\" \"58\" \"58\" \"58\"\n",
       "[376] \"59\" \"59\" \"59\" \"59\" \"59\" \"60\" \"60\" \"60\" \"60\" \"60\" \"60\" \"61\" \"61\" \"61\" \"61\"\n",
       "[391] \"61\" \"61\" \"61\" \"61\" \"61\" \"62\" \"62\" \"62\" \"62\" \"62\" \"62\" \"62\" \"63\" \"63\" \"63\"\n",
       "[406] \"63\" \"63\" \"64\" \"64\" \"64\" \"65\" \"65\" \"65\" \"65\" \"66\" \"66\" \"67\" \"68\" \"68\" \"69\"\n",
       "[421] \"69\" \"70\" \"70\" \"72\" \"73\" \"74\" \"63\" \"44\" \"60\" \"55\" \"66\" \"66\" \"65\" \"60\" \"60\"\n",
       "[436] \"60\" \"56\" \"59\" \"62\" \"63\" \"57\" \"62\" \"63\" \"46\" \"63\" \"60\" \"58\" \"64\" \"63\" \"74\"\n",
       "[451] \"52\" \"69\" \"51\" \"60\" \"56\" \"55\" \"54\" \"77\" \"63\" \"55\" \"52\" \"64\" \"60\" \"60\" \"58\"\n",
       "[466] \"59\" \"61\" \"40\" \"61\" \"41\" \"57\" \"63\" \"59\" \"51\" \"59\" \"42\" \"55\" \"63\" \"62\" \"56\"\n",
       "[481] \"53\" \"68\" \"53\" \"60\" \"62\" \"59\" \"51\" \"61\" \"57\" \"56\" \"58\" \"69\" \"67\" \"58\" \"65\"\n",
       "[496] \"63\" \"55\" \"57\" \"65\" \"54\" \"72\" \"75\" \"49\" \"51\" \"60\" \"64\" \"58\" \"61\" \"67\" \"62\"\n",
       "[511] \"65\" \"63\" \"69\" \"51\" \"62\" \"55\" \"75\" \"40\" \"67\" \"58\" \"60\" \"63\" \"35\" \"62\" \"43\"\n",
       "[526] \"63\" \"68\" \"65\" \"48\" \"63\" \"64\" \"61\" \"50\" \"59\" \"55\" \"45\" \"65\" \"61\" \"49\" \"72\"\n",
       "[541] \"50\" \"64\" \"55\" \"63\" \"59\" \"56\" \"62\" \"74\" \"54\" \"57\" \"62\" \"76\" \"54\" \"70\" \"61\"\n",
       "[556] \"48\" \"48\" \"61\" \"66\" \"68\" \"55\" \"62\" \"71\" \"74\" \"53\" \"58\" \"75\" \"56\" \"58\" \"64\"\n",
       "[571] \"54\" \"54\" \"59\" \"55\" \"57\" \"61\" \"41\" \"71\" \"38\" \"55\" \"56\" \"69\" \"64\" \"72\" \"69\"\n",
       "[586] \"56\" \"62\" \"67\" \"57\" \"69\" \"51\" \"48\" \"69\" \"69\" \"64\" \"57\" \"53\" \"37\" \"67\" \"74\"\n",
       "[601] \"63\" \"58\" \"61\" \"64\" \"58\" \"60\" \"57\" \"55\" \"55\" \"56\" \"57\" \"61\" \"61\" \"58\" \"74\"\n",
       "[616] \"68\" \"51\" \"62\" \"53\" \"62\" \"46\" \"54\" \"62\" \"55\" \"58\" \"62\" \"28\" \"29\" \"29\" \"30\"\n",
       "[631] \"31\" \"32\" \"32\" \"32\" \"33\" \"34\" \"34\" \"34\" \"35\" \"35\" \"35\" \"35\" \"36\" \"36\" \"36\"\n",
       "[646] \"36\" \"37\" \"37\" \"37\" \"37\" \"37\" \"37\" \"37\" \"38\" \"38\" \"38\" \"39\" \"39\" \"39\" \"39\"\n",
       "[661] \"39\" \"39\" \"39\" \"39\" \"39\" \"39\" \"40\" \"40\" \"40\" \"40\" \"40\" \"41\" \"41\" \"41\" \"41\"\n",
       "[676] \"41\" \"41\" \"41\" \"42\" \"42\" \"42\" \"42\" \"42\" \"42\" \"42\" \"43\" \"43\" \"43\" \"43\" \"43\"\n",
       "[691] \"43\" \"43\" \"43\" \"44\" \"44\" \"44\" \"44\" \"45\" \"45\" \"45\" \"45\" \"45\" \"45\" \"45\" \"46\"\n",
       "[706] \"46\" \"46\" \"46\" \"46\" \"46\" \"46\" \"47\" \"47\" \"47\" \"47\" \"47\" \"48\" \"48\" \"48\" \"48\"\n",
       "[721] \"48\" \"48\" \"48\" \"48\" \"48\" \"48\" \"48\" \"49\" \"49\" \"49\" \"49\" \"49\" \"49\" \"49\" \"49\"\n",
       "[736] \"50\" \"50\" \"50\" \"50\" \"50\" \"50\" \"50\" \"51\" \"51\" \"51\" \"51\" \"51\" \"51\" \"51\" \"52\"\n",
       "[751] \"52\" \"52\" \"52\" \"52\" \"52\" \"52\" \"52\" \"53\" \"53\" \"53\" \"53\" \"53\" \"53\" \"53\" \"53\"\n",
       "[766] \"53\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\" \"54\"\n",
       "[781] \"54\" \"54\" \"55\" \"55\" \"55\" \"55\" \"55\" \"55\" \"55\" \"55\" \"55\" \"55\" \"56\" \"56\" \"56\"\n",
       "[796] \"56\" \"56\" \"57\" \"57\" \"57\" \"58\" \"58\" \"58\" \"58\" \"59\" \"59\" \"59\" \"59\" \"59\" \"60\"\n",
       "[811] \"61\" \"61\" \"62\" \"62\" \"31\" \"33\" \"34\" \"35\" \"36\" \"37\" \"38\" \"38\" \"38\" \"40\" \"41\"\n",
       "[826] \"41\" \"43\" \"46\" \"46\" \"46\" \"47\" \"47\" \"48\" \"48\" \"48\" \"49\" \"49\" \"49\" \"50\" \"50\"\n",
       "[841] \"51\" \"52\" \"54\" \"54\" \"55\" \"57\" \"58\" \"59\" \"60\" \"63\" \"65\" \"32\" \"38\" \"39\" \"40\"\n",
       "[856] \"43\" \"45\" \"46\" \"46\" \"48\" \"48\" \"48\" \"48\" \"50\" \"52\" \"52\" \"53\" \"54\" \"54\" \"54\"\n",
       "[871] \"54\" \"54\" \"55\" \"56\" \"57\" \"58\" \"58\" \"41\" \"43\" \"44\" \"44\" \"46\" \"47\" \"48\" \"49\"\n",
       "[886] \"49\" \"51\" \"52\" \"52\" \"52\" \"52\" \"53\" \"53\" \"54\" \"55\" \"55\" \"55\" \"56\" \"56\" \"56\"\n",
       "[901] \"58\" \"59\" \"59\" \"65\" \"66\" \"41\" \"43\" \"44\" \"47\" \"47\" \"49\" \"49\" \"50\" \"50\" \"52\"\n",
       "[916] \"52\" \"54\" \"56\" \"58\" \"65\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>age</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>63</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>67</td></tr>\n",
       "\t<tr><th scope=row>3</th><td>67</td></tr>\n",
       "\t<tr><th scope=row>4</th><td>37</td></tr>\n",
       "\t<tr><th scope=row>5</th><td>41</td></tr>\n",
       "\t<tr><th scope=row>6</th><td>56</td></tr>\n",
       "\t<tr><th scope=row>7</th><td>62</td></tr>\n",
       "\t<tr><th scope=row>8</th><td>57</td></tr>\n",
       "\t<tr><th scope=row>9</th><td>63</td></tr>\n",
       "\t<tr><th scope=row>10</th><td>53</td></tr>\n",
       "\t<tr><th scope=row>11</th><td>57</td></tr>\n",
       "\t<tr><th scope=row>12</th><td>56</td></tr>\n",
       "\t<tr><th scope=row>13</th><td>56</td></tr>\n",
       "\t<tr><th scope=row>14</th><td>44</td></tr>\n",
       "\t<tr><th scope=row>15</th><td>52</td></tr>\n",
       "\t<tr><th scope=row>16</th><td>57</td></tr>\n",
       "\t<tr><th scope=row>17</th><td>48</td></tr>\n",
       "\t<tr><th scope=row>18</th><td>54</td></tr>\n",
       "\t<tr><th scope=row>19</th><td>48</td></tr>\n",
       "\t<tr><th scope=row>20</th><td>49</td></tr>\n",
       "\t<tr><th scope=row>21</th><td>64</td></tr>\n",
       "\t<tr><th scope=row>22</th><td>58</td></tr>\n",
       "\t<tr><th scope=row>23</th><td>58</td></tr>\n",
       "\t<tr><th scope=row>24</th><td>58</td></tr>\n",
       "\t<tr><th scope=row>25</th><td>60</td></tr>\n",
       "\t<tr><th scope=row>26</th><td>50</td></tr>\n",
       "\t<tr><th scope=row>27</th><td>58</td></tr>\n",
       "\t<tr><th scope=row>28</th><td>66</td></tr>\n",
       "\t<tr><th scope=row>29</th><td>43</td></tr>\n",
       "\t<tr><th scope=row>30</th><td>40</td></tr>\n",
       "\t<tr><th scope=row>31</th><td><e2><8b><ae></td></tr>\n",
       "\t<tr><th scope=row>891</th><td>52</td></tr>\n",
       "\t<tr><th scope=row>892</th><td>53</td></tr>\n",
       "\t<tr><th scope=row>893</th><td>53</td></tr>\n",
       "\t<tr><th scope=row>894</th><td>54</td></tr>\n",
       "\t<tr><th scope=row>895</th><td>55</td></tr>\n",
       "\t<tr><th scope=row>896</th><td>55</td></tr>\n",
       "\t<tr><th scope=row>897</th><td>55</td></tr>\n",
       "\t<tr><th scope=row>898</th><td>56</td></tr>\n",
       "\t<tr><th scope=row>899</th><td>56</td></tr>\n",
       "\t<tr><th scope=row>900</th><td>56</td></tr>\n",
       "\t<tr><th scope=row>901</th><td>58</td></tr>\n",
       "\t<tr><th scope=row>902</th><td>59</td></tr>\n",
       "\t<tr><th scope=row>903</th><td>59</td></tr>\n",
       "\t<tr><th scope=row>904</th><td>65</td></tr>\n",
       "\t<tr><th scope=row>905</th><td>66</td></tr>\n",
       "\t<tr><th scope=row>906</th><td>41</td></tr>\n",
       "\t<tr><th scope=row>907</th><td>43</td></tr>\n",
       "\t<tr><th scope=row>908</th><td>44</td></tr>\n",
       "\t<tr><th scope=row>909</th><td>47</td></tr>\n",
       "\t<tr><th scope=row>910</th><td>47</td></tr>\n",
       "\t<tr><th scope=row>911</th><td>49</td></tr>\n",
       "\t<tr><th scope=row>912</th><td>49</td></tr>\n",
       "\t<tr><th scope=row>913</th><td>50</td></tr>\n",
       "\t<tr><th scope=row>914</th><td>50</td></tr>\n",
       "\t<tr><th scope=row>915</th><td>52</td></tr>\n",
       "\t<tr><th scope=row>916</th><td>52</td></tr>\n",
       "\t<tr><th scope=row>917</th><td>54</td></tr>\n",
       "\t<tr><th scope=row>918</th><td>56</td></tr>\n",
       "\t<tr><th scope=row>919</th><td>58</td></tr>\n",
       "\t<tr><th scope=row>920</th><td>65</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|l}\n",
       "  & age\\\\\n",
       "\\hline\n",
       "\t1 & 63\\\\\n",
       "\t2 & 67\\\\\n",
       "\t3 & 67\\\\\n",
       "\t4 & 37\\\\\n",
       "\t5 & 41\\\\\n",
       "\t6 & 56\\\\\n",
       "\t7 & 62\\\\\n",
       "\t8 & 57\\\\\n",
       "\t9 & 63\\\\\n",
       "\t10 & 53\\\\\n",
       "\t11 & 57\\\\\n",
       "\t12 & 56\\\\\n",
       "\t13 & 56\\\\\n",
       "\t14 & 44\\\\\n",
       "\t15 & 52\\\\\n",
       "\t16 & 57\\\\\n",
       "\t17 & 48\\\\\n",
       "\t18 & 54\\\\\n",
       "\t19 & 48\\\\\n",
       "\t20 & 49\\\\\n",
       "\t21 & 64\\\\\n",
       "\t22 & 58\\\\\n",
       "\t23 & 58\\\\\n",
       "\t24 & 58\\\\\n",
       "\t25 & 60\\\\\n",
       "\t26 & 50\\\\\n",
       "\t27 & 58\\\\\n",
       "\t28 & 66\\\\\n",
       "\t29 & 43\\\\\n",
       "\t30 & 40\\\\\n",
       "\t31 & <e2><8b><ae>\\\\\n",
       "\t891 & 52\\\\\n",
       "\t892 & 53\\\\\n",
       "\t893 & 53\\\\\n",
       "\t894 & 54\\\\\n",
       "\t895 & 55\\\\\n",
       "\t896 & 55\\\\\n",
       "\t897 & 55\\\\\n",
       "\t898 & 56\\\\\n",
       "\t899 & 56\\\\\n",
       "\t900 & 56\\\\\n",
       "\t901 & 58\\\\\n",
       "\t902 & 59\\\\\n",
       "\t903 & 59\\\\\n",
       "\t904 & 65\\\\\n",
       "\t905 & 66\\\\\n",
       "\t906 & 41\\\\\n",
       "\t907 & 43\\\\\n",
       "\t908 & 44\\\\\n",
       "\t909 & 47\\\\\n",
       "\t910 & 47\\\\\n",
       "\t911 & 49\\\\\n",
       "\t912 & 49\\\\\n",
       "\t913 & 50\\\\\n",
       "\t914 & 50\\\\\n",
       "\t915 & 52\\\\\n",
       "\t916 & 52\\\\\n",
       "\t917 & 54\\\\\n",
       "\t918 & 56\\\\\n",
       "\t919 & 58\\\\\n",
       "\t920 & 65\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "    age\n",
       "1    63\n",
       "2    67\n",
       "3    67\n",
       "4    37\n",
       "5    41\n",
       "6    56\n",
       "7    62\n",
       "8    57\n",
       "9    63\n",
       "10   53\n",
       "11   57\n",
       "12   56\n",
       "13   56\n",
       "14   44\n",
       "15   52\n",
       "16   57\n",
       "17   48\n",
       "18   54\n",
       "19   48\n",
       "20   49\n",
       "21   64\n",
       "22   58\n",
       "23   58\n",
       "24   58\n",
       "25   60\n",
       "26   50\n",
       "27   58\n",
       "28   66\n",
       "29   43\n",
       "30   40\n",
       "31   69\n",
       "32   60\n",
       "33   64\n",
       "34   59\n",
       "35   44\n",
       "36   42\n",
       "37   43\n",
       "38   57\n",
       "39   55\n",
       "40   61\n",
       "41   65\n",
       "42   40\n",
       "43   71\n",
       "44   59\n",
       "45   61\n",
       "46   58\n",
       "47   51\n",
       "48   50\n",
       "49   65\n",
       "50   53\n",
       "51   41\n",
       "52   65\n",
       "53   44\n",
       "54   44\n",
       "55   60\n",
       "56   54\n",
       "57   50\n",
       "58   41\n",
       "59   54\n",
       "60   51\n",
       "61   51\n",
       "62   46\n",
       "63   58\n",
       "64   54\n",
       "65   54\n",
       "66   60\n",
       "67   60\n",
       "68   54\n",
       "69   59\n",
       "70   46\n",
       "71   65\n",
       "72   67\n",
       "73   62\n",
       "74   65\n",
       "75   44\n",
       "76   65\n",
       "77   60\n",
       "78   51\n",
       "79   48\n",
       "80   58\n",
       "81   45\n",
       "82   53\n",
       "83   39\n",
       "84   68\n",
       "85   52\n",
       "86   44\n",
       "87   47\n",
       "88   53\n",
       "89   53\n",
       "90   51\n",
       "91   66\n",
       "92   62\n",
       "93   62\n",
       "94   44\n",
       "95   63\n",
       "96   52\n",
       "97   59\n",
       "98   60\n",
       "99   52\n",
       "100  48\n",
       "101  45\n",
       "102  34\n",
       "103  57\n",
       "104  71\n",
       "105  49\n",
       "106  54\n",
       "107  59\n",
       "108  57\n",
       "109  61\n",
       "110  39\n",
       "111  61\n",
       "112  56\n",
       "113  52\n",
       "114  43\n",
       "115  62\n",
       "116  41\n",
       "117  58\n",
       "118  35\n",
       "119  63\n",
       "120  65\n",
       "121  48\n",
       "122  63\n",
       "123  51\n",
       "124  55\n",
       "125  65\n",
       "126  45\n",
       "127  56\n",
       "128  54\n",
       "129  44\n",
       "130  62\n",
       "131  54\n",
       "132  51\n",
       "133  29\n",
       "134  51\n",
       "135  43\n",
       "136  55\n",
       "137  70\n",
       "138  62\n",
       "139  35\n",
       "140  51\n",
       "141  59\n",
       "142  59\n",
       "143  52\n",
       "144  64\n",
       "145  58\n",
       "146  47\n",
       "147  57\n",
       "148  41\n",
       "149  45\n",
       "150  60\n",
       "151  52\n",
       "152  42\n",
       "153  67\n",
       "154  55\n",
       "155  64\n",
       "156  70\n",
       "157  51\n",
       "158  58\n",
       "159  60\n",
       "160  68\n",
       "161  46\n",
       "162  77\n",
       "163  54\n",
       "164  58\n",
       "165  48\n",
       "166  57\n",
       "167  52\n",
       "168  54\n",
       "169  35\n",
       "170  45\n",
       "171  70\n",
       "172  53\n",
       "173  59\n",
       "174  62\n",
       "175  64\n",
       "176  57\n",
       "177  52\n",
       "178  56\n",
       "179  43\n",
       "180  53\n",
       "181  48\n",
       "182  56\n",
       "183  42\n",
       "184  59\n",
       "185  60\n",
       "186  63\n",
       "187  42\n",
       "188  66\n",
       "189  54\n",
       "190  69\n",
       "191  50\n",
       "192  51\n",
       "193  43\n",
       "194  62\n",
       "195  68\n",
       "196  67\n",
       "197  69\n",
       "198  45\n",
       "199  50\n",
       "200  59\n",
       "201  50\n",
       "202  64\n",
       "203  57\n",
       "204  64\n",
       "205  43\n",
       "206  45\n",
       "207  58\n",
       "208  50\n",
       "209  55\n",
       "210  62\n",
       "211  37\n",
       "212  38\n",
       "213  41\n",
       "214  66\n",
       "215  52\n",
       "216  56\n",
       "217  46\n",
       "218  46\n",
       "219  64\n",
       "220  59\n",
       "221  41\n",
       "222  54\n",
       "223  39\n",
       "224  53\n",
       "225  63\n",
       "226  34\n",
       "227  47\n",
       "228  67\n",
       "229  54\n",
       "230  66\n",
       "231  52\n",
       "232  55\n",
       "233  49\n",
       "234  74\n",
       "235  54\n",
       "236  54\n",
       "237  56\n",
       "238  46\n",
       "239  49\n",
       "240  42\n",
       "241  41\n",
       "242  41\n",
       "243  49\n",
       "244  61\n",
       "245  60\n",
       "246  67\n",
       "247  58\n",
       "248  47\n",
       "249  52\n",
       "250  62\n",
       "251  57\n",
       "252  58\n",
       "253  64\n",
       "254  51\n",
       "255  43\n",
       "256  42\n",
       "257  67\n",
       "258  76\n",
       "259  70\n",
       "260  57\n",
       "261  44\n",
       "262  58\n",
       "263  60\n",
       "264  44\n",
       "265  61\n",
       "266  42\n",
       "267  52\n",
       "268  59\n",
       "269  40\n",
       "270  42\n",
       "271  61\n",
       "272  66\n",
       "273  46\n",
       "274  71\n",
       "275  59\n",
       "276  64\n",
       "277  66\n",
       "278  39\n",
       "279  57\n",
       "280  58\n",
       "281  57\n",
       "282  47\n",
       "283  55\n",
       "284  35\n",
       "285  61\n",
       "286  58\n",
       "287  58\n",
       "288  58\n",
       "289  56\n",
       "290  56\n",
       "291  67\n",
       "292  55\n",
       "293  44\n",
       "294  63\n",
       "295  63\n",
       "296  41\n",
       "297  59\n",
       "298  57\n",
       "299  45\n",
       "300  68\n",
       "301  57\n",
       "302  57\n",
       "303  38\n",
       "304  32\n",
       "305  34\n",
       "306  35\n",
       "307  36\n",
       "308  38\n",
       "309  38\n",
       "310  38\n",
       "311  38\n",
       "312  38\n",
       "313  38\n",
       "314  40\n",
       "315  41\n",
       "316  42\n",
       "317  42\n",
       "318  43\n",
       "319  43\n",
       "320  43\n",
       "321  45\n",
       "322  46\n",
       "323  46\n",
       "324  47\n",
       "325  47\n",
       "326  47\n",
       "327  47\n",
       "328  48\n",
       "329  50\n",
       "330  50\n",
       "331  50\n",
       "332  50\n",
       "333  51\n",
       "334  51\n",
       "335  51\n",
       "336  51\n",
       "337  51\n",
       "338  51\n",
       "339  51\n",
       "340  52\n",
       "341  52\n",
       "342  52\n",
       "343  52\n",
       "344  53\n",
       "345  53\n",
       "346  53\n",
       "347  53\n",
       "348  53\n",
       "349  53\n",
       "350  53\n",
       "351  53\n",
       "352  54\n",
       "353  54\n",
       "354  54\n",
       "355  55\n",
       "356  55\n",
       "357  55\n",
       "358  55\n",
       "359  56\n",
       "360  56\n",
       "361  56\n",
       "362  56\n",
       "363  56\n",
       "364  56\n",
       "365  56\n",
       "366  56\n",
       "367  57\n",
       "368  57\n",
       "369  57\n",
       "370  57\n",
       "371  57\n",
       "372  57\n",
       "373  58\n",
       "374  58\n",
       "375  58\n",
       "376  59\n",
       "377  59\n",
       "378  59\n",
       "379  59\n",
       "380  59\n",
       "381  60\n",
       "382  60\n",
       "383  60\n",
       "384  60\n",
       "385  60\n",
       "386  60\n",
       "387  61\n",
       "388  61\n",
       "389  61\n",
       "390  61\n",
       "391  61\n",
       "392  61\n",
       "393  61\n",
       "394  61\n",
       "395  61\n",
       "396  62\n",
       "397  62\n",
       "398  62\n",
       "399  62\n",
       "400  62\n",
       "401  62\n",
       "402  62\n",
       "403  63\n",
       "404  63\n",
       "405  63\n",
       "406  63\n",
       "407  63\n",
       "408  64\n",
       "409  64\n",
       "410  64\n",
       "411  65\n",
       "412  65\n",
       "413  65\n",
       "414  65\n",
       "415  66\n",
       "416  66\n",
       "417  67\n",
       "418  68\n",
       "419  68\n",
       "420  69\n",
       "421  69\n",
       "422  70\n",
       "423  70\n",
       "424  72\n",
       "425  73\n",
       "426  74\n",
       "427  63\n",
       "428  44\n",
       "429  60\n",
       "430  55\n",
       "431  66\n",
       "432  66\n",
       "433  65\n",
       "434  60\n",
       "435  60\n",
       "436  60\n",
       "437  56\n",
       "438  59\n",
       "439  62\n",
       "440  63\n",
       "441  57\n",
       "442  62\n",
       "443  63\n",
       "444  46\n",
       "445  63\n",
       "446  60\n",
       "447  58\n",
       "448  64\n",
       "449  63\n",
       "450  74\n",
       "451  52\n",
       "452  69\n",
       "453  51\n",
       "454  60\n",
       "455  56\n",
       "456  55\n",
       "457  54\n",
       "458  77\n",
       "459  63\n",
       "460  55\n",
       "461  52\n",
       "462  64\n",
       "463  60\n",
       "464  60\n",
       "465  58\n",
       "466  59\n",
       "467  61\n",
       "468  40\n",
       "469  61\n",
       "470  41\n",
       "471  57\n",
       "472  63\n",
       "473  59\n",
       "474  51\n",
       "475  59\n",
       "476  42\n",
       "477  55\n",
       "478  63\n",
       "479  62\n",
       "480  56\n",
       "481  53\n",
       "482  68\n",
       "483  53\n",
       "484  60\n",
       "485  62\n",
       "486  59\n",
       "487  51\n",
       "488  61\n",
       "489  57\n",
       "490  56\n",
       "491  58\n",
       "492  69\n",
       "493  67\n",
       "494  58\n",
       "495  65\n",
       "496  63\n",
       "497  55\n",
       "498  57\n",
       "499  65\n",
       "500  54\n",
       "501  72\n",
       "502  75\n",
       "503  49\n",
       "504  51\n",
       "505  60\n",
       "506  64\n",
       "507  58\n",
       "508  61\n",
       "509  67\n",
       "510  62\n",
       "511  65\n",
       "512  63\n",
       "513  69\n",
       "514  51\n",
       "515  62\n",
       "516  55\n",
       "517  75\n",
       "518  40\n",
       "519  67\n",
       "520  58\n",
       "521  60\n",
       "522  63\n",
       "523  35\n",
       "524  62\n",
       "525  43\n",
       "526  63\n",
       "527  68\n",
       "528  65\n",
       "529  48\n",
       "530  63\n",
       "531  64\n",
       "532  61\n",
       "533  50\n",
       "534  59\n",
       "535  55\n",
       "536  45\n",
       "537  65\n",
       "538  61\n",
       "539  49\n",
       "540  72\n",
       "541  50\n",
       "542  64\n",
       "543  55\n",
       "544  63\n",
       "545  59\n",
       "546  56\n",
       "547  62\n",
       "548  74\n",
       "549  54\n",
       "550  57\n",
       "551  62\n",
       "552  76\n",
       "553  54\n",
       "554  70\n",
       "555  61\n",
       "556  48\n",
       "557  48\n",
       "558  61\n",
       "559  66\n",
       "560  68\n",
       "561  55\n",
       "562  62\n",
       "563  71\n",
       "564  74\n",
       "565  53\n",
       "566  58\n",
       "567  75\n",
       "568  56\n",
       "569  58\n",
       "570  64\n",
       "571  54\n",
       "572  54\n",
       "573  59\n",
       "574  55\n",
       "575  57\n",
       "576  61\n",
       "577  41\n",
       "578  71\n",
       "579  38\n",
       "580  55\n",
       "581  56\n",
       "582  69\n",
       "583  64\n",
       "584  72\n",
       "585  69\n",
       "586  56\n",
       "587  62\n",
       "588  67\n",
       "589  57\n",
       "590  69\n",
       "591  51\n",
       "592  48\n",
       "593  69\n",
       "594  69\n",
       "595  64\n",
       "596  57\n",
       "597  53\n",
       "598  37\n",
       "599  67\n",
       "600  74\n",
       "601  63\n",
       "602  58\n",
       "603  61\n",
       "604  64\n",
       "605  58\n",
       "606  60\n",
       "607  57\n",
       "608  55\n",
       "609  55\n",
       "610  56\n",
       "611  57\n",
       "612  61\n",
       "613  61\n",
       "614  58\n",
       "615  74\n",
       "616  68\n",
       "617  51\n",
       "618  62\n",
       "619  53\n",
       "620  62\n",
       "621  46\n",
       "622  54\n",
       "623  62\n",
       "624  55\n",
       "625  58\n",
       "626  62\n",
       "627  28\n",
       "628  29\n",
       "629  29\n",
       "630  30\n",
       "631  31\n",
       "632  32\n",
       "633  32\n",
       "634  32\n",
       "635  33\n",
       "636  34\n",
       "637  34\n",
       "638  34\n",
       "639  35\n",
       "640  35\n",
       "641  35\n",
       "642  35\n",
       "643  36\n",
       "644  36\n",
       "645  36\n",
       "646  36\n",
       "647  37\n",
       "648  37\n",
       "649  37\n",
       "650  37\n",
       "651  37\n",
       "652  37\n",
       "653  37\n",
       "654  38\n",
       "655  38\n",
       "656  38\n",
       "657  39\n",
       "658  39\n",
       "659  39\n",
       "660  39\n",
       "661  39\n",
       "662  39\n",
       "663  39\n",
       "664  39\n",
       "665  39\n",
       "666  39\n",
       "667  40\n",
       "668  40\n",
       "669  40\n",
       "670  40\n",
       "671  40\n",
       "672  41\n",
       "673  41\n",
       "674  41\n",
       "675  41\n",
       "676  41\n",
       "677  41\n",
       "678  41\n",
       "679  42\n",
       "680  42\n",
       "681  42\n",
       "682  42\n",
       "683  42\n",
       "684  42\n",
       "685  42\n",
       "686  43\n",
       "687  43\n",
       "688  43\n",
       "689  43\n",
       "690  43\n",
       "691  43\n",
       "692  43\n",
       "693  43\n",
       "694  44\n",
       "695  44\n",
       "696  44\n",
       "697  44\n",
       "698  45\n",
       "699  45\n",
       "700  45\n",
       "701  45\n",
       "702  45\n",
       "703  45\n",
       "704  45\n",
       "705  46\n",
       "706  46\n",
       "707  46\n",
       "708  46\n",
       "709  46\n",
       "710  46\n",
       "711  46\n",
       "712  47\n",
       "713  47\n",
       "714  47\n",
       "715  47\n",
       "716  47\n",
       "717  48\n",
       "718  48\n",
       "719  48\n",
       "720  48\n",
       "721  48\n",
       "722  48\n",
       "723  48\n",
       "724  48\n",
       "725  48\n",
       "726  48\n",
       "727  48\n",
       "728  49\n",
       "729  49\n",
       "730  49\n",
       "731  49\n",
       "732  49\n",
       "733  49\n",
       "734  49\n",
       "735  49\n",
       "736  50\n",
       "737  50\n",
       "738  50\n",
       "739  50\n",
       "740  50\n",
       "741  50\n",
       "742  50\n",
       "743  51\n",
       "744  51\n",
       "745  51\n",
       "746  51\n",
       "747  51\n",
       "748  51\n",
       "749  51\n",
       "750  52\n",
       "751  52\n",
       "752  52\n",
       "753  52\n",
       "754  52\n",
       "755  52\n",
       "756  52\n",
       "757  52\n",
       "758  53\n",
       "759  53\n",
       "760  53\n",
       "761  53\n",
       "762  53\n",
       "763  53\n",
       "764  53\n",
       "765  53\n",
       "766  53\n",
       "767  54\n",
       "768  54\n",
       "769  54\n",
       "770  54\n",
       "771  54\n",
       "772  54\n",
       "773  54\n",
       "774  54\n",
       "775  54\n",
       "776  54\n",
       "777  54\n",
       "778  54\n",
       "779  54\n",
       "780  54\n",
       "781  54\n",
       "782  54\n",
       "783  55\n",
       "784  55\n",
       "785  55\n",
       "786  55\n",
       "787  55\n",
       "788  55\n",
       "789  55\n",
       "790  55\n",
       "791  55\n",
       "792  55\n",
       "793  56\n",
       "794  56\n",
       "795  56\n",
       "796  56\n",
       "797  56\n",
       "798  57\n",
       "799  57\n",
       "800  57\n",
       "801  58\n",
       "802  58\n",
       "803  58\n",
       "804  58\n",
       "805  59\n",
       "806  59\n",
       "807  59\n",
       "808  59\n",
       "809  59\n",
       "810  60\n",
       "811  61\n",
       "812  61\n",
       "813  62\n",
       "814  62\n",
       "815  31\n",
       "816  33\n",
       "817  34\n",
       "818  35\n",
       "819  36\n",
       "820  37\n",
       "821  38\n",
       "822  38\n",
       "823  38\n",
       "824  40\n",
       "825  41\n",
       "826  41\n",
       "827  43\n",
       "828  46\n",
       "829  46\n",
       "830  46\n",
       "831  47\n",
       "832  47\n",
       "833  48\n",
       "834  48\n",
       "835  48\n",
       "836  49\n",
       "837  49\n",
       "838  49\n",
       "839  50\n",
       "840  50\n",
       "841  51\n",
       "842  52\n",
       "843  54\n",
       "844  54\n",
       "845  55\n",
       "846  57\n",
       "847  58\n",
       "848  59\n",
       "849  60\n",
       "850  63\n",
       "851  65\n",
       "852  32\n",
       "853  38\n",
       "854  39\n",
       "855  40\n",
       "856  43\n",
       "857  45\n",
       "858  46\n",
       "859  46\n",
       "860  48\n",
       "861  48\n",
       "862  48\n",
       "863  48\n",
       "864  50\n",
       "865  52\n",
       "866  52\n",
       "867  53\n",
       "868  54\n",
       "869  54\n",
       "870  54\n",
       "871  54\n",
       "872  54\n",
       "873  55\n",
       "874  56\n",
       "875  57\n",
       "876  58\n",
       "877  58\n",
       "878  41\n",
       "879  43\n",
       "880  44\n",
       "881  44\n",
       "882  46\n",
       "883  47\n",
       "884  48\n",
       "885  49\n",
       "886  49\n",
       "887  51\n",
       "888  52\n",
       "889  52\n",
       "890  52\n",
       "891  52\n",
       "892  53\n",
       "893  53\n",
       "894  54\n",
       "895  55\n",
       "896  55\n",
       "897  55\n",
       "898  56\n",
       "899  56\n",
       "900  56\n",
       "901  58\n",
       "902  59\n",
       "903  59\n",
       "904  65\n",
       "905  66\n",
       "906  41\n",
       "907  43\n",
       "908  44\n",
       "909  47\n",
       "910  47\n",
       "911  49\n",
       "912  49\n",
       "913  50\n",
       "914  50\n",
       "915  52\n",
       "916  52\n",
       "917  54\n",
       "918  56\n",
       "919  58\n",
       "920  65"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#===========================================================\n",
    "#R\n",
    "# the variable names are embedded into the structure but accessed using a $ character\n",
    "df$age\n",
    "df['age'] # but can also be accessed using strings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 4 inf\n"
     ]
    }
   ],
   "source": [
    "#Pandas\n",
    "print df.chest_pain.min(), df.chest_pain.max(), df.chest_pain.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Warning message:\n",
      "In mean.default(df$chest_pain): argument is not numeric or logical: returning NA"
     ]
    },
    {
     "data": {
      "text/html": [
       "\"1 4 NA\""
      ],
      "text/latex": [
       "\"1 4 NA\""
      ],
      "text/markdown": [
       "\"1 4 NA\""
      ],
      "text/plain": [
       "[1] \"1 4 NA\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "paste(min(df$chest_pain), max(df$chest_pain), mean(df$chest_pain), sep=\" \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null object\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null object\n",
      "rest_blood_press     920 non-null object\n",
      "cholesterol          920 non-null object\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null object\n",
      "max_heart_rate       920 non-null object\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null object\n",
      "Peak_ST_seg          920 non-null object\n",
      "major_vessels        920 non-null object\n",
      "thal                 920 non-null object\n",
      "has_heart_disease    920 non-null object\n",
      "dtypes: object(14)None\n"
     ]
    }
   ],
   "source": [
    "#Pandas\n",
    "# lets get rid of the 'site' variable\n",
    "if 'site' in df:\n",
    "    del df['site']\n",
    "\n",
    "print df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'data.frame':\t920 obs. of  14 variables:\n",
      " $ age              : chr  \"63\" \"67\" \"67\" \"37\" ...\n",
      " $ is_male          : chr  \"1\" \"1\" \"1\" \"1\" ...\n",
      " $ chest_pain       : chr  \"1\" \"4\" \"4\" \"3\" ...\n",
      " $ rest_blood_press : chr  \"145\" \"160\" \"120\" \"130\" ...\n",
      " $ cholesterol      : chr  \"233\" \"286\" \"229\" \"250\" ...\n",
      " $ high_blood_sugar : chr  \"1\" \"0\" \"0\" \"0\" ...\n",
      " $ rest_ecg         : chr  \"2\" \"2\" \"2\" \"0\" ...\n",
      " $ max_heart_rate   : chr  \"150\" \"108\" \"129\" \"187\" ...\n",
      " $ exer_angina      : chr  \"0\" \"1\" \"1\" \"0\" ...\n",
      " $ ST_depression    : chr  \"2.3\" \"1.5\" \"2.6\" \"3.5\" ...\n",
      " $ Peak_ST_seg      : chr  \"3\" \"2\" \"2\" \"3\" ...\n",
      " $ major_vessels    : chr  \"0\" \"3\" \"2\" \"0\" ...\n",
      " $ thal             : chr  \"6\" \"3\" \"7\" \"3\" ...\n",
      " $ has_heart_disease: chr  \"0\" \"2\" \"1\" \"0\" ...\n"
     ]
    }
   ],
   "source": [
    "#R\n",
    "# lets get rid of the 'site' variable using R\n",
    "#df[ SUBSET ROWS HERE , SUBSET COLUMNS HERE]\n",
    "#See the follwing URL for a million different alternate examples:\n",
    "#    http://stackoverflow.com/questions/4605206/drop-data-frame-columns-by-name\n",
    "df <- df[, !(colnames(df) %in% c(\"site\"))] \n",
    "\n",
    "#do the same thing using the column index, CAREFUL, IF you run this twice, age will be gone as well!\n",
    "#This is litterally saying select all columns, except the column at index 1\n",
    "#df <- df[, -1] \n",
    "\n",
    "str(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     920 non-null float64\n",
      "cholesterol          920 non-null float64\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null int64\n",
      "max_heart_rate       920 non-null float64\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null float64\n",
      "Peak_ST_seg          920 non-null int64\n",
      "major_vessels        920 non-null int64\n",
      "thal                 920 non-null int64\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: float64(4), int64(7), object(3)"
     ]
    }
   ],
   "source": [
    "#Pandas\n",
    "# Notice that all of the data is stored as a non-null object\n",
    "# That's not good. It means we need to change those data types\n",
    "# in order to encode the variables properly. Right now Pandas\n",
    "# thinks all of our variables are nominal!\n",
    "\n",
    "import numpy as np\n",
    "# replace '?' with -1, we will deal with missing values later\n",
    "df = df.replace(to_replace='?',value=-999) \n",
    "\n",
    "# let's start by first changing the numeric values to be floats\n",
    "continuous_features = ['rest_blood_press', 'cholesterol', \n",
    "                       'max_heart_rate', 'ST_depression']\n",
    "\n",
    "# and the oridnal values to be integers\n",
    "ordinal_features = ['age','major_vessels','chest_pain',\n",
    "                    'rest_ecg','Peak_ST_seg','thal','has_heart_disease']\n",
    "\n",
    "# we won't touch these variables, keep them as categorical\n",
    "categ_features = ['is_male','high_blood_sugar','exer_angina'];\n",
    "\n",
    "# use the \"astype\" function to change the variable type\n",
    "df[continuous_features] = df[continuous_features].astype(np.float64)\n",
    "df[ordinal_features] = df[ordinal_features].astype(np.int64)\n",
    "\n",
    "df.info() # now our data looks better!!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'data.frame':\t920 obs. of  14 variables:\n",
      " $ age              : num  63 67 67 37 41 56 62 57 63 53 ...\n",
      " $ is_male          : Factor w/ 2 levels \"0\",\"1\": 2 2 2 2 1 2 1 1 2 2 ...\n",
      " $ chest_pain       : num  1 4 4 3 2 2 4 4 4 4 ...\n",
      " $ rest_blood_press : num  145 160 120 130 130 120 140 120 130 140 ...\n",
      " $ cholesterol      : num  233 286 229 250 204 236 268 354 254 203 ...\n",
      " $ high_blood_sugar : Factor w/ 3 levels \"-999\",\"0\",\"1\": 3 2 2 2 2 2 2 2 2 3 ...\n",
      " $ rest_ecg         : num  2 2 2 0 2 0 2 0 2 2 ...\n",
      " $ max_heart_rate   : num  150 108 129 187 172 178 160 163 147 155 ...\n",
      " $ exer_angina      : Factor w/ 3 levels \"-999\",\"0\",\"1\": 2 3 3 2 2 2 2 3 2 3 ...\n",
      " $ ST_depression    : num  2.3 1.5 2.6 3.5 1.4 0.8 3.6 0.6 1.4 3.1 ...\n",
      " $ Peak_ST_seg      : num  3 2 2 3 1 1 3 1 2 3 ...\n",
      " $ major_vessels    : num  0 3 2 0 0 0 2 0 1 0 ...\n",
      " $ thal             : num  6 3 7 3 3 3 3 3 7 7 ...\n",
      " $ has_heart_disease: num  0 2 1 0 0 0 3 0 2 1 ...\n"
     ]
    }
   ],
   "source": [
    "#===========================================================\n",
    "#R\n",
    "# Notice that all of the data is stored as character vectors.\n",
    "# That's not good. It means we need to change those data types\n",
    "# in order to encode the variables properly. Right now R\n",
    "# thinks all of our variables are nominal!\n",
    "\n",
    "# replace '?' with -999, we will deal with missing values later\n",
    "df[df == '?'] <- -999\n",
    "\n",
    "# let's start by first changing the numeric values to be floats\n",
    "continuous_features = c('rest_blood_press', 'cholesterol', \n",
    "                       'max_heart_rate', 'ST_depression')\n",
    "\n",
    "# and the oridnal values to be integers\n",
    "ordinal_features = c('age','major_vessels','chest_pain',\n",
    "                    'rest_ecg','Peak_ST_seg','thal','has_heart_disease')\n",
    "\n",
    "# we won't touch these variables, keep them as categorical\n",
    "categ_features = c('is_male','high_blood_sugar','exer_angina')\n",
    "\n",
    "# use the sapply function to change the variable type\n",
    "df[ , continuous_features] <- lapply(df[,continuous_features],as.numeric)\n",
    "df[ , ordinal_features] <- lapply(df[,ordinal_features],as.numeric)\n",
    "df[ , categ_features] <- lapply(df[,categ_features],as.factor)\n",
    "\n",
    "str(df) # now our data looks better!!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>is_male</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>high_blood_sugar</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>exer_angina</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td> 63</td>\n",
       "      <td> 1</td>\n",
       "      <td> 1</td>\n",
       "      <td> 145</td>\n",
       "      <td> 233</td>\n",
       "      <td> 1</td>\n",
       "      <td> 2</td>\n",
       "      <td> 150</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2.3</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td> 67</td>\n",
       "      <td> 1</td>\n",
       "      <td> 4</td>\n",
       "      <td> 160</td>\n",
       "      <td> 286</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 108</td>\n",
       "      <td> 1</td>\n",
       "      <td> 1.5</td>\n",
       "      <td> 2</td>\n",
       "      <td> 3</td>\n",
       "      <td> 3</td>\n",
       "      <td> 2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td> 67</td>\n",
       "      <td> 1</td>\n",
       "      <td> 4</td>\n",
       "      <td> 120</td>\n",
       "      <td> 229</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 129</td>\n",
       "      <td> 1</td>\n",
       "      <td> 2.6</td>\n",
       "      <td> 2</td>\n",
       "      <td> 2</td>\n",
       "      <td> 7</td>\n",
       "      <td> 1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td> 37</td>\n",
       "      <td> 1</td>\n",
       "      <td> 3</td>\n",
       "      <td> 130</td>\n",
       "      <td> 250</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 187</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3.5</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td> 41</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 130</td>\n",
       "      <td> 204</td>\n",
       "      <td> 0</td>\n",
       "      <td> 2</td>\n",
       "      <td> 172</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1.4</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 3</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age is_male  chest_pain  rest_blood_press  cholesterol high_blood_sugar  \\\n",
       "0   63       1           1               145          233                1   \n",
       "1   67       1           4               160          286                0   \n",
       "2   67       1           4               120          229                0   \n",
       "3   37       1           3               130          250                0   \n",
       "4   41       0           2               130          204                0   \n",
       "\n",
       "   rest_ecg  max_heart_rate exer_angina  ST_depression  Peak_ST_seg  \\\n",
       "0         2             150           0            2.3            3   \n",
       "1         2             108           1            1.5            2   \n",
       "2         2             129           1            2.6            2   \n",
       "3         0             187           0            3.5            3   \n",
       "4         2             172           0            1.4            1   \n",
       "\n",
       "   major_vessels  thal  has_heart_disease  \n",
       "0              0     6                  0  \n",
       "1              3     3                  2  \n",
       "2              2     7                  1  \n",
       "3              0     3                  0  \n",
       "4              0     3                  0  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>age</th><th scope=col>is_male</th><th scope=col>chest_pain</th><th scope=col>rest_blood_press</th><th scope=col>cholesterol</th><th scope=col>high_blood_sugar</th><th scope=col>rest_ecg</th><th scope=col>max_heart_rate</th><th scope=col>exer_angina</th><th scope=col>ST_depression</th><th scope=col>Peak_ST_seg</th><th scope=col>major_vessels</th><th scope=col>thal</th><th scope=col>has_heart_disease</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>63</td><td>1</td><td>1</td><td>145</td><td>233</td><td>1</td><td>2</td><td>150</td><td>0</td><td>2.3</td><td>3</td><td>0</td><td>6</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>67</td><td>1</td><td>4</td><td>160</td><td>286</td><td>0</td><td>2</td><td>108</td><td>1</td><td>1.5</td><td>2</td><td>3</td><td>3</td><td>2</td></tr>\n",
       "\t<tr><th scope=row>3</th><td>67</td><td>1</td><td>4</td><td>120</td><td>229</td><td>0</td><td>2</td><td>129</td><td>1</td><td>2.6</td><td>2</td><td>2</td><td>7</td><td>1</td></tr>\n",
       "\t<tr><th scope=row>4</th><td>37</td><td>1</td><td>3</td><td>130</td><td>250</td><td>0</td><td>0</td><td>187</td><td>0</td><td>3.5</td><td>3</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>5</th><td>41</td><td>0</td><td>2</td><td>130</td><td>204</td><td>0</td><td>2</td><td>172</td><td>0</td><td>1.4</td><td>1</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "\t<tr><th scope=row>6</th><td>56</td><td>1</td><td>2</td><td>120</td><td>236</td><td>0</td><td>0</td><td>178</td><td>0</td><td>0.8</td><td>1</td><td>0</td><td>3</td><td>0</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllllllllllll}\n",
       "  & age & is_male & chest_pain & rest_blood_press & cholesterol & high_blood_sugar & rest_ecg & max_heart_rate & exer_angina & ST_depression & Peak_ST_seg & major_vessels & thal & has_heart_disease\\\\\n",
       "\\hline\n",
       "\t1 & 63 & 1 & 1 & 145 & 233 & 1 & 2 & 150 & 0 & 2.3 & 3 & 0 & 6 & 0\\\\\n",
       "\t2 & 67 & 1 & 4 & 160 & 286 & 0 & 2 & 108 & 1 & 1.5 & 2 & 3 & 3 & 2\\\\\n",
       "\t3 & 67 & 1 & 4 & 120 & 229 & 0 & 2 & 129 & 1 & 2.6 & 2 & 2 & 7 & 1\\\\\n",
       "\t4 & 37 & 1 & 3 & 130 & 250 & 0 & 0 & 187 & 0 & 3.5 & 3 & 0 & 3 & 0\\\\\n",
       "\t5 & 41 & 0 & 2 & 130 & 204 & 0 & 2 & 172 & 0 & 1.4 & 1 & 0 & 3 & 0\\\\\n",
       "\t6 & 56 & 1 & 2 & 120 & 236 & 0 & 0 & 178 & 0 & 0.8 & 1 & 0 & 3 & 0\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "  age is_male chest_pain rest_blood_press cholesterol high_blood_sugar rest_ecg\n",
       "1  63       1          1              145         233                1        2\n",
       "2  67       1          4              160         286                0        2\n",
       "3  67       1          4              120         229                0        2\n",
       "4  37       1          3              130         250                0        0\n",
       "5  41       0          2              130         204                0        2\n",
       "6  56       1          2              120         236                0        0\n",
       "  max_heart_rate exer_angina ST_depression Peak_ST_seg major_vessels thal\n",
       "1            150           0           2.3           3             0    6\n",
       "2            108           1           1.5           2             3    3\n",
       "3            129           1           2.6           2             2    7\n",
       "4            187           0           3.5           3             0    3\n",
       "5            172           0           1.4           1             0    3\n",
       "6            178           0           0.8           1             0    3\n",
       "  has_heart_disease\n",
       "1                 0\n",
       "2                 2\n",
       "3                 1\n",
       "4                 0\n",
       "5                 0\n",
       "6                 0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "head(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's get summary of all attributes in the frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>  53.510870</td>\n",
       "      <td>   3.250000</td>\n",
       "      <td> 123.594565</td>\n",
       "      <td> 192.604348</td>\n",
       "      <td>   0.601087</td>\n",
       "      <td> 129.263043</td>\n",
       "      <td>   0.752174</td>\n",
       "      <td>   0.840217</td>\n",
       "      <td>  -0.436957</td>\n",
       "      <td>   1.871739</td>\n",
       "      <td>   0.995652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>   9.424685</td>\n",
       "      <td>   0.930969</td>\n",
       "      <td>  37.484705</td>\n",
       "      <td> 114.615011</td>\n",
       "      <td>   0.808415</td>\n",
       "      <td>  41.376773</td>\n",
       "      <td>   1.154353</td>\n",
       "      <td>   1.403211</td>\n",
       "      <td>   0.959656</td>\n",
       "      <td>   3.313649</td>\n",
       "      <td>   1.142693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>  28.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -2.600000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>  47.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td> 120.000000</td>\n",
       "      <td> 164.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td> 115.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>  54.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "      <td> 130.000000</td>\n",
       "      <td> 221.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td> 138.000000</td>\n",
       "      <td>   0.200000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>  -1.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>  60.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "      <td> 140.000000</td>\n",
       "      <td> 267.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td> 156.000000</td>\n",
       "      <td>   1.500000</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   6.000000</td>\n",
       "      <td>   2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>  77.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "      <td> 200.000000</td>\n",
       "      <td> 603.000000</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td> 202.000000</td>\n",
       "      <td>   6.200000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   7.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              age  chest_pain  rest_blood_press  cholesterol    rest_ecg  \\\n",
       "count  920.000000  920.000000        920.000000   920.000000  920.000000   \n",
       "mean    53.510870    3.250000        123.594565   192.604348    0.601087   \n",
       "std      9.424685    0.930969         37.484705   114.615011    0.808415   \n",
       "min     28.000000    1.000000         -1.000000    -1.000000   -1.000000   \n",
       "25%     47.000000    3.000000        120.000000   164.000000    0.000000   \n",
       "50%     54.000000    4.000000        130.000000   221.000000    0.000000   \n",
       "75%     60.000000    4.000000        140.000000   267.000000    1.000000   \n",
       "max     77.000000    4.000000        200.000000   603.000000    2.000000   \n",
       "\n",
       "       max_heart_rate  ST_depression  Peak_ST_seg  major_vessels        thal  \\\n",
       "count      920.000000     920.000000   920.000000     920.000000  920.000000   \n",
       "mean       129.263043       0.752174     0.840217      -0.436957    1.871739   \n",
       "std         41.376773       1.154353     1.403211       0.959656    3.313649   \n",
       "min         -1.000000      -2.600000    -1.000000      -1.000000   -1.000000   \n",
       "25%        115.000000       0.000000    -1.000000      -1.000000   -1.000000   \n",
       "50%        138.000000       0.200000     1.000000      -1.000000   -1.000000   \n",
       "75%        156.000000       1.500000     2.000000       0.000000    6.000000   \n",
       "max        202.000000       6.200000     3.000000       3.000000    7.000000   \n",
       "\n",
       "       has_heart_disease  \n",
       "count         920.000000  \n",
       "mean            0.995652  \n",
       "std             1.142693  \n",
       "min             0.000000  \n",
       "25%             0.000000  \n",
       "50%             1.000000  \n",
       "75%             2.000000  \n",
       "max             4.000000  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "df.describe() # will get summary of continuous or the nominals"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      age        is_male   chest_pain   rest_blood_press   cholesterol    \n",
       " Min.   :28.00   0:194   Min.   :1.00   Min.   :-999.00   Min.   :-999.0  \n",
       " 1st Qu.:47.00   1:726   1st Qu.:3.00   1st Qu.: 120.00   1st Qu.: 164.0  \n",
       " Median :54.00           Median :4.00   Median : 130.00   Median : 221.0  \n",
       " Mean   :53.51           Mean   :3.25   Mean   :  59.59   Mean   : 160.1  \n",
       " 3rd Qu.:60.00           3rd Qu.:4.00   3rd Qu.: 140.00   3rd Qu.: 267.0  \n",
       " Max.   :77.00           Max.   :4.00   Max.   : 200.00   Max.   : 603.0  \n",
       " high_blood_sugar    rest_ecg        max_heart_rate   exer_angina\n",
       " -999: 90         Min.   :-999.000   Min.   :-999.0   -999: 55   \n",
       " 0   :692         1st Qu.:   0.000   1st Qu.: 115.0   0   :528   \n",
       " 1   :138         Median :   0.000   Median : 138.0   1   :337   \n",
       "                  Mean   :  -1.568   Mean   :  69.6              \n",
       "                  3rd Qu.:   1.000   3rd Qu.: 156.0              \n",
       "                  Max.   :   2.000   Max.   : 202.0              \n",
       " ST_depression     Peak_ST_seg     major_vessels         thal       \n",
       " Min.   :-999.0   Min.   :-999.0   Min.   :-999.0   Min.   :-999.0  \n",
       " 1st Qu.:   0.0   1st Qu.:-999.0   1st Qu.:-999.0   1st Qu.:-999.0  \n",
       " Median :   0.2   Median :   1.0   Median :-999.0   Median :-999.0  \n",
       " Mean   : -66.5   Mean   :-334.4   Mean   :-663.2   Mean   :-525.3  \n",
       " 3rd Qu.:   1.5   3rd Qu.:   2.0   3rd Qu.:   0.0   3rd Qu.:   6.0  \n",
       " Max.   :   6.2   Max.   :   3.0   Max.   :   3.0   Max.   :   7.0  \n",
       " has_heart_disease\n",
       " Min.   :0.0000   \n",
       " 1st Qu.:0.0000   \n",
       " Median :1.0000   \n",
       " Mean   :0.9957   \n",
       " 3rd Qu.:2.0000   \n",
       " Max.   :4.0000   "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "summary(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are 920 entries in this data frame. Notice that this data frame has a number of missing values denoted by the value -999 (that we changed the '?' value to before). We need to either remove the missing values from the dataset OR we need to fill in with our best guess for those values. Let's first drop all the rows with missing values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     861 non-null float64\n",
      "cholesterol          890 non-null float64\n",
      "high_blood_sugar     830 non-null object\n",
      "rest_ecg             918 non-null float64\n",
      "max_heart_rate       865 non-null float64\n",
      "exer_angina          865 non-null object\n",
      "ST_depression        856 non-null float64\n",
      "Peak_ST_seg          611 non-null float64\n",
      "major_vessels        309 non-null float64\n",
      "thal                 434 non-null float64\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: float64(8), int64(3), object(3)None\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "      <td> 861.000000</td>\n",
       "      <td> 890.000000</td>\n",
       "      <td> 918.000000</td>\n",
       "      <td> 865.000000</td>\n",
       "      <td> 856.000000</td>\n",
       "      <td> 611.000000</td>\n",
       "      <td> 309.000000</td>\n",
       "      <td> 434.000000</td>\n",
       "      <td> 920.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>  53.510870</td>\n",
       "      <td>   3.250000</td>\n",
       "      <td> 132.132404</td>\n",
       "      <td> 199.130337</td>\n",
       "      <td>   0.604575</td>\n",
       "      <td> 137.545665</td>\n",
       "      <td>   0.883178</td>\n",
       "      <td>   1.770867</td>\n",
       "      <td>   0.676375</td>\n",
       "      <td>   5.087558</td>\n",
       "      <td>   0.995652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>   9.424685</td>\n",
       "      <td>   0.930969</td>\n",
       "      <td>  19.066070</td>\n",
       "      <td> 110.780810</td>\n",
       "      <td>   0.805827</td>\n",
       "      <td>  25.926276</td>\n",
       "      <td>   1.088707</td>\n",
       "      <td>   0.619256</td>\n",
       "      <td>   0.935653</td>\n",
       "      <td>   1.919075</td>\n",
       "      <td>   1.142693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>  28.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>  60.000000</td>\n",
       "      <td>  -2.600000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>  47.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td> 120.000000</td>\n",
       "      <td> 175.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td> 120.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>  54.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "      <td> 130.000000</td>\n",
       "      <td> 223.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td> 140.000000</td>\n",
       "      <td>   0.500000</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   6.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>  60.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "      <td> 140.000000</td>\n",
       "      <td> 268.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td> 157.000000</td>\n",
       "      <td>   1.500000</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>   7.000000</td>\n",
       "      <td>   2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>  77.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "      <td> 200.000000</td>\n",
       "      <td> 603.000000</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td> 202.000000</td>\n",
       "      <td>   6.200000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   7.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              age  chest_pain  rest_blood_press  cholesterol    rest_ecg  \\\n",
       "count  920.000000  920.000000        861.000000   890.000000  918.000000   \n",
       "mean    53.510870    3.250000        132.132404   199.130337    0.604575   \n",
       "std      9.424685    0.930969         19.066070   110.780810    0.805827   \n",
       "min     28.000000    1.000000          0.000000     0.000000    0.000000   \n",
       "25%     47.000000    3.000000        120.000000   175.000000    0.000000   \n",
       "50%     54.000000    4.000000        130.000000   223.000000    0.000000   \n",
       "75%     60.000000    4.000000        140.000000   268.000000    1.000000   \n",
       "max     77.000000    4.000000        200.000000   603.000000    2.000000   \n",
       "\n",
       "       max_heart_rate  ST_depression  Peak_ST_seg  major_vessels        thal  \\\n",
       "count      865.000000     856.000000   611.000000     309.000000  434.000000   \n",
       "mean       137.545665       0.883178     1.770867       0.676375    5.087558   \n",
       "std         25.926276       1.088707     0.619256       0.935653    1.919075   \n",
       "min         60.000000      -2.600000     1.000000       0.000000    3.000000   \n",
       "25%        120.000000       0.000000     1.000000       0.000000    3.000000   \n",
       "50%        140.000000       0.500000     2.000000       0.000000    6.000000   \n",
       "75%        157.000000       1.500000     2.000000       1.000000    7.000000   \n",
       "max        202.000000       6.200000     3.000000       3.000000    7.000000   \n",
       "\n",
       "       has_heart_disease  \n",
       "count         920.000000  \n",
       "mean            0.995652  \n",
       "std             1.142693  \n",
       "min             0.000000  \n",
       "25%             0.000000  \n",
       "50%             1.000000  \n",
       "75%             2.000000  \n",
       "max             4.000000  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# how many value have the -1 (which we set as the missing values) \n",
    "import numpy as np\n",
    "\n",
    "# let's set those values to NaN, so that Pandas understand they are missing\n",
    "df = df.replace(to_replace=-999,value=np.nan) # replace -1 with NaN (not a number)\n",
    "print df.info()\n",
    "df.describe() # scroll over to see the values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "1759"
      ],
      "text/latex": [
       "1759"
      ],
      "text/markdown": [
       "1759"
      ],
      "text/plain": [
       "[1] 1759"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "1759"
      ],
      "text/latex": [
       "1759"
      ],
      "text/markdown": [
       "1759"
      ],
      "text/plain": [
       "[1] 1759"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'data.frame':\t920 obs. of  14 variables:\n",
      " $ age              : num  63 67 67 37 41 56 62 57 63 53 ...\n",
      " $ is_male          : Factor w/ 2 levels \"0\",\"1\": 2 2 2 2 1 2 1 1 2 2 ...\n",
      " $ chest_pain       : num  1 4 4 3 2 2 4 4 4 4 ...\n",
      " $ rest_blood_press : num  145 160 120 130 130 120 140 120 130 140 ...\n",
      " $ cholesterol      : num  233 286 229 250 204 236 268 354 254 203 ...\n",
      " $ high_blood_sugar : Factor w/ 3 levels \"-999\",\"0\",\"1\": 3 2 2 2 2 2 2 2 2 3 ...\n",
      " $ rest_ecg         : num  2 2 2 0 2 0 2 0 2 2 ...\n",
      " $ max_heart_rate   : num  150 108 129 187 172 178 160 163 147 155 ...\n",
      " $ exer_angina      : Factor w/ 3 levels \"-999\",\"0\",\"1\": 2 3 3 2 2 2 2 3 2 3 ...\n",
      " $ ST_depression    : num  2.3 1.5 2.6 3.5 1.4 0.8 3.6 0.6 1.4 3.1 ...\n",
      " $ Peak_ST_seg      : num  3 2 2 3 1 1 3 1 2 3 ...\n",
      " $ major_vessels    : num  0 3 2 0 0 0 2 0 1 0 ...\n",
      " $ thal             : num  6 3 7 3 3 3 3 3 7 7 ...\n",
      " $ has_heart_disease: num  0 2 1 0 0 0 3 0 2 1 ...\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "      age        is_male   chest_pain   rest_blood_press  cholesterol   \n",
       " Min.   :28.00   0:194   Min.   :1.00   Min.   :  0.0    Min.   :  0.0  \n",
       " 1st Qu.:47.00   1:726   1st Qu.:3.00   1st Qu.:120.0    1st Qu.:175.0  \n",
       " Median :54.00           Median :4.00   Median :130.0    Median :223.0  \n",
       " Mean   :53.51           Mean   :3.25   Mean   :132.1    Mean   :199.1  \n",
       " 3rd Qu.:60.00           3rd Qu.:4.00   3rd Qu.:140.0    3rd Qu.:268.0  \n",
       " Max.   :77.00           Max.   :4.00   Max.   :200.0    Max.   :603.0  \n",
       "                                        NA's   :59       NA's   :30     \n",
       " high_blood_sugar    rest_ecg      max_heart_rate  exer_angina\n",
       " -999:  0         Min.   :0.0000   Min.   : 60.0   -999:  0   \n",
       " 0   :692         1st Qu.:0.0000   1st Qu.:120.0   0   :528   \n",
       " 1   :138         Median :0.0000   Median :140.0   1   :337   \n",
       " NA's: 90         Mean   :0.6046   Mean   :137.5   NA's: 55   \n",
       "                  3rd Qu.:1.0000   3rd Qu.:157.0              \n",
       "                  Max.   :2.0000   Max.   :202.0              \n",
       "                  NA's   :2        NA's   :55                 \n",
       " ST_depression      Peak_ST_seg    major_vessels         thal      \n",
       " Min.   :-2.6000   Min.   :1.000   Min.   :0.0000   Min.   :3.000  \n",
       " 1st Qu.: 0.0000   1st Qu.:1.000   1st Qu.:0.0000   1st Qu.:3.000  \n",
       " Median : 0.5000   Median :2.000   Median :0.0000   Median :6.000  \n",
       " Mean   : 0.8788   Mean   :1.771   Mean   :0.6764   Mean   :5.088  \n",
       " 3rd Qu.: 1.5000   3rd Qu.:2.000   3rd Qu.:1.0000   3rd Qu.:7.000  \n",
       " Max.   : 6.2000   Max.   :3.000   Max.   :3.0000   Max.   :7.000  \n",
       " NA's   :62        NA's   :309     NA's   :611      NA's   :486    \n",
       " has_heart_disease\n",
       " Min.   :0.0000   \n",
       " 1st Qu.:0.0000   \n",
       " Median :1.0000   \n",
       " Mean   :0.9957   \n",
       " 3rd Qu.:2.0000   \n",
       " Max.   :4.0000   \n",
       "                  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "# how many values were previously ? (which we set as the missing values) \n",
    "length(df[df == '-999'])  #Count the  -999 values\n",
    "\n",
    "# let's set those values to NA, so that R understand they are missing\n",
    "df[df == '-999'] <- NA\n",
    "\n",
    "# how many values were previously -999 (which we set as the missing values) \n",
    "sum(is.na(df))\n",
    "\n",
    "str(df)\n",
    "summary(df) # scroll over to see the values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Wow. Notice how the number of attributes went down in the description function. Looks like we need to impute values. If we drop the rows with missing data, we will be throwing away almost 80% of the data collected. No way!!\n",
    "\n",
    "### Imputation of NaN values (Optional)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "age                   54.0\n",
       "is_male                1.0\n",
       "chest_pain             4.0\n",
       "rest_blood_press     130.0\n",
       "cholesterol          223.0\n",
       "high_blood_sugar       0.0\n",
       "rest_ecg               0.0\n",
       "max_heart_rate       140.0\n",
       "exer_angina            0.0\n",
       "ST_depression          0.5\n",
       "Peak_ST_seg            2.0\n",
       "major_vessels          0.0\n",
       "thal                   6.0\n",
       "has_heart_disease      1.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "# lets look at some stats of the data\n",
    "df.median() # only calculates for numeric data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      age        is_male   chest_pain   rest_blood_press  cholesterol   \n",
       " Min.   :28.00   0:194   Min.   :1.00   Min.   :  0.0    Min.   :  0.0  \n",
       " 1st Qu.:47.00   1:726   1st Qu.:3.00   1st Qu.:120.0    1st Qu.:175.0  \n",
       " Median :54.00           Median :4.00   Median :130.0    Median :223.0  \n",
       " Mean   :53.51           Mean   :3.25   Mean   :132.1    Mean   :199.1  \n",
       " 3rd Qu.:60.00           3rd Qu.:4.00   3rd Qu.:140.0    3rd Qu.:268.0  \n",
       " Max.   :77.00           Max.   :4.00   Max.   :200.0    Max.   :603.0  \n",
       "                                        NA's   :59       NA's   :30     \n",
       " high_blood_sugar    rest_ecg      max_heart_rate  exer_angina\n",
       " -999:  0         Min.   :0.0000   Min.   : 60.0   -999:  0   \n",
       " 0   :692         1st Qu.:0.0000   1st Qu.:120.0   0   :528   \n",
       " 1   :138         Median :0.0000   Median :140.0   1   :337   \n",
       " NA's: 90         Mean   :0.6046   Mean   :137.5   NA's: 55   \n",
       "                  3rd Qu.:1.0000   3rd Qu.:157.0              \n",
       "                  Max.   :2.0000   Max.   :202.0              \n",
       "                  NA's   :2        NA's   :55                 \n",
       " ST_depression      Peak_ST_seg    major_vessels         thal      \n",
       " Min.   :-2.6000   Min.   :1.000   Min.   :0.0000   Min.   :3.000  \n",
       " 1st Qu.: 0.0000   1st Qu.:1.000   1st Qu.:0.0000   1st Qu.:3.000  \n",
       " Median : 0.5000   Median :2.000   Median :0.0000   Median :6.000  \n",
       " Mean   : 0.8788   Mean   :1.771   Mean   :0.6764   Mean   :5.088  \n",
       " 3rd Qu.: 1.5000   3rd Qu.:2.000   3rd Qu.:1.0000   3rd Qu.:7.000  \n",
       " Max.   : 6.2000   Max.   :3.000   Max.   :3.0000   Max.   :7.000  \n",
       " NA's   :62        NA's   :309     NA's   :611      NA's   :486    \n",
       " has_heart_disease\n",
       " Min.   :0.0000   \n",
       " 1st Qu.:0.0000   \n",
       " Median :1.0000   \n",
       " Mean   :0.9957   \n",
       " 3rd Qu.:2.0000   \n",
       " Max.   :4.0000   \n",
       "                  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "# lets look at some stats of the data\n",
    "summary(df) # only calculates for numeric data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     920 non-null float64\n",
      "cholesterol          920 non-null float64\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null float64\n",
      "max_heart_rate       920 non-null float64\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null float64\n",
      "Peak_ST_seg          920 non-null float64\n",
      "major_vessels        920 non-null float64\n",
      "thal                 920 non-null float64\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: float64(8), int64(3), object(3)"
     ]
    }
   ],
   "source": [
    "#Pandas\n",
    "# the 'fillna' function will take the given series (the output above)\n",
    "# and fill in the missing values for the columns it has\n",
    "df_imputed = df.fillna(df.median()) # note that to do this all values must be numeric\n",
    "df_imputed.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice that the object variables are unchanged, but all the numeric/ordinal values have been filled in with the median of the columns. Let's try something (slightly) smarter, and fill in the oridinals with the median and the continuous with the mean."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      age        is_male   chest_pain   rest_blood_press  cholesterol   \n",
       " Min.   :28.00   0:194   Min.   :1.00   Min.   :  0.0    Min.   :  0.0  \n",
       " 1st Qu.:47.00   1:726   1st Qu.:3.00   1st Qu.:120.0    1st Qu.:177.8  \n",
       " Median :54.00           Median :4.00   Median :130.0    Median :221.0  \n",
       " Mean   :53.51           Mean   :3.25   Mean   :132.1    Mean   :199.1  \n",
       " 3rd Qu.:60.00           3rd Qu.:4.00   3rd Qu.:140.0    3rd Qu.:267.0  \n",
       " Max.   :77.00           Max.   :4.00   Max.   :200.0    Max.   :603.0  \n",
       " high_blood_sugar    rest_ecg      max_heart_rate  exer_angina\n",
       " -999:  0         Min.   :0.0000   Min.   : 60.0   -999:  0   \n",
       " 0   :692         1st Qu.:0.0000   1st Qu.:120.0   0   :528   \n",
       " 1   :138         Median :0.0000   Median :138.0   1   :337   \n",
       " NA's: 90         Mean   :0.6046   Mean   :137.5   NA's: 55   \n",
       "                  3rd Qu.:1.0000   3rd Qu.:156.0              \n",
       "                  Max.   :2.0000   Max.   :202.0              \n",
       " ST_depression      Peak_ST_seg    major_vessels         thal      \n",
       " Min.   :-2.6000   Min.   :1.000   Min.   :0.0000   Min.   :3.000  \n",
       " 1st Qu.: 0.0000   1st Qu.:1.771   1st Qu.:0.6764   1st Qu.:5.088  \n",
       " Median : 0.8000   Median :1.771   Median :0.6764   Median :5.088  \n",
       " Mean   : 0.8788   Mean   :1.771   Mean   :0.6764   Mean   :5.088  \n",
       " 3rd Qu.: 1.5000   3rd Qu.:2.000   3rd Qu.:0.6764   3rd Qu.:6.000  \n",
       " Max.   : 6.2000   Max.   :3.000   Max.   :3.0000   Max.   :7.000  \n",
       " has_heart_disease\n",
       " Min.   :0.0000   \n",
       " 1st Qu.:0.0000   \n",
       " Median :1.0000   \n",
       " Mean   :0.9957   \n",
       " 3rd Qu.:2.0000   \n",
       " Max.   :4.0000   "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "# the lapply function will take the given series (the output above)\n",
    "# and fill in the missing values for the columns it has\n",
    "\n",
    "df_imputed <- df\n",
    "\n",
    "#Get only the numeric columns in the data frame\n",
    "numCols <- sapply(df, is.numeric)\n",
    "\n",
    "#Now perform Simple Mean Imputation on each numeric column\n",
    "df_imputed[,numCols] <- lapply(df_imputed[,numCols], function(x) { \n",
    "  x[is.na(x)] <- mean(x, na.rm = TRUE)\n",
    "  x\n",
    "})\n",
    "\n",
    "summary(df_imputed)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice all of the NA values are now imputed / replaced with the mean() for each column."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "is_male                1.000000\n",
      "high_blood_sugar       0.000000\n",
      "exer_angina            0.000000\n",
      "age                   54.000000\n",
      "major_vessels          0.000000\n",
      "chest_pain             4.000000\n",
      "rest_ecg               0.000000\n",
      "Peak_ST_seg            2.000000\n",
      "thal                   6.000000\n",
      "has_heart_disease      1.000000\n",
      "rest_blood_press     132.132404\n",
      "cholesterol          199.130337\n",
      "max_heart_rate       137.545665\n",
      "ST_depression          0.883178\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "# Pandas\n",
    "# make  one series for imputing with\n",
    "series_mean = df[continuous_features].mean()\n",
    "series_median = df[categ_features+ordinal_features].median()\n",
    "cat_series = pd.concat((series_median,series_mean))\n",
    "\n",
    "print cat_series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     920 non-null float64\n",
      "cholesterol          920 non-null float64\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null float64\n",
      "max_heart_rate       920 non-null float64\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null float64\n",
      "Peak_ST_seg          920 non-null float64\n",
      "major_vessels        920 non-null float64\n",
      "thal                 920 non-null float64\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: float64(8), int64(3), object(3)"
     ]
    }
   ],
   "source": [
    "# Pandas\n",
    "# now let's impute the numbers a bit differently\n",
    "\n",
    "df_imputed = df.fillna(value=cat_series)\n",
    "df_imputed.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      age        is_male   chest_pain   rest_blood_press  cholesterol   \n",
       " Min.   :28.00   0:194   Min.   :1.00   Min.   :  0.0    Min.   :  0.0  \n",
       " 1st Qu.:47.00   1:726   1st Qu.:3.00   1st Qu.:120.0    1st Qu.:177.8  \n",
       " Median :54.00           Median :4.00   Median :130.0    Median :221.0  \n",
       " Mean   :53.51           Mean   :3.25   Mean   :132.1    Mean   :199.1  \n",
       " 3rd Qu.:60.00           3rd Qu.:4.00   3rd Qu.:140.0    3rd Qu.:267.0  \n",
       " Max.   :77.00           Max.   :4.00   Max.   :200.0    Max.   :603.0  \n",
       "                                                                        \n",
       " high_blood_sugar    rest_ecg      max_heart_rate  exer_angina\n",
       " -999:  0         Min.   :0.0000   Min.   : 60.0   -999:  0   \n",
       " 0   :692         1st Qu.:0.0000   1st Qu.:120.0   0   :528   \n",
       " 1   :138         Median :0.0000   Median :138.0   1   :337   \n",
       " NA's: 90         Mean   :0.6046   Mean   :137.5   NA's: 55   \n",
       "                  3rd Qu.:1.0000   3rd Qu.:156.0              \n",
       "                  Max.   :2.0000   Max.   :202.0              \n",
       "                  NA's   :2                                   \n",
       " ST_depression      Peak_ST_seg    major_vessels         thal      \n",
       " Min.   :-2.6000   Min.   :1.000   Min.   :0.0000   Min.   :3.000  \n",
       " 1st Qu.: 0.0000   1st Qu.:1.000   1st Qu.:0.0000   1st Qu.:3.000  \n",
       " Median : 0.8000   Median :2.000   Median :0.0000   Median :6.000  \n",
       " Mean   : 0.8788   Mean   :1.771   Mean   :0.6764   Mean   :5.088  \n",
       " 3rd Qu.: 1.5000   3rd Qu.:2.000   3rd Qu.:1.0000   3rd Qu.:7.000  \n",
       " Max.   : 6.2000   Max.   :3.000   Max.   :3.0000   Max.   :7.000  \n",
       "                   NA's   :309     NA's   :611      NA's   :486    \n",
       " has_heart_disease\n",
       " Min.   :0.0000   \n",
       " 1st Qu.:0.0000   \n",
       " Median :1.0000   \n",
       " Mean   :0.9957   \n",
       " 3rd Qu.:2.0000   \n",
       " Max.   :4.0000   \n",
       "                  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "# impute with the mean for the continuous features\n",
    "df_imputed <- df\n",
    "\n",
    "df_imputed[,continuous_features] <- lapply(df_imputed[,continuous_features], function(x) { \n",
    "  x[is.na(x)] <- mean(x, na.rm = TRUE)\n",
    "  x\n",
    "})\n",
    "\n",
    "# impute with the median for the categ_features + ordinal_features\n",
    "df_imputed[,c(continuous_features, ordinal_features)] <- lapply(df_imputed[,c(continuous_features, ordinal_features)], function(x) { \n",
    "  x[is.na(x)] <- median(x)\n",
    "  x\n",
    "})\n",
    "\n",
    "summary(df_imputed)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>is_male</th>\n",
       "      <th>high_blood_sugar</th>\n",
       "      <th>exer_angina</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td> 920</td>\n",
       "      <td> 920</td>\n",
       "      <td> 920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>unique</th>\n",
       "      <td>   2</td>\n",
       "      <td>   3</td>\n",
       "      <td>   3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>top</th>\n",
       "      <td>   1</td>\n",
       "      <td>   0</td>\n",
       "      <td>   0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>freq</th>\n",
       "      <td> 726</td>\n",
       "      <td> 692</td>\n",
       "      <td> 528</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       is_male high_blood_sugar exer_angina\n",
       "count      920              920         920\n",
       "unique       2                3           3\n",
       "top          1                0           0\n",
       "freq       726              692         528"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Pandas\n",
    "df_imputed[categ_features].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       " is_male high_blood_sugar exer_angina\n",
       " 0:194   -999:  0         -999:  0   \n",
       " 1:726   0   :692         0   :528   \n",
       "         1   :138         1   :337   \n",
       "         NA's: 90         NA's: 55   "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "summary(df_imputed[, categ_features])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Indexing logically into Data Frames\n",
    "Let's now say that we are only interested in the summary of the dataframe when the patient has heart disease. We can achieve this using a few line of code:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411.000000</td>\n",
       "      <td> 411</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>  50.547445</td>\n",
       "      <td>   2.761557</td>\n",
       "      <td> 130.021042</td>\n",
       "      <td> 226.575368</td>\n",
       "      <td>   0.547445</td>\n",
       "      <td> 148.252830</td>\n",
       "      <td>   0.441963</td>\n",
       "      <td>   1.729927</td>\n",
       "      <td>   0.111922</td>\n",
       "      <td>   5.085158</td>\n",
       "      <td>   0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>   9.433700</td>\n",
       "      <td>   0.903425</td>\n",
       "      <td>  16.460208</td>\n",
       "      <td>  74.301504</td>\n",
       "      <td>   0.805204</td>\n",
       "      <td>  23.152969</td>\n",
       "      <td>   0.704565</td>\n",
       "      <td>   0.515662</td>\n",
       "      <td>   0.427276</td>\n",
       "      <td>   1.510951</td>\n",
       "      <td>   0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>  28.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>  80.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>  69.000000</td>\n",
       "      <td>  -1.100000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>  43.000000</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td> 120.000000</td>\n",
       "      <td> 199.130337</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td> 135.500000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>  51.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td> 130.000000</td>\n",
       "      <td> 225.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td> 150.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   6.000000</td>\n",
       "      <td>   0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>  57.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "      <td> 140.000000</td>\n",
       "      <td> 266.000000</td>\n",
       "      <td>   1.000000</td>\n",
       "      <td> 165.000000</td>\n",
       "      <td>   0.883178</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td>   0.000000</td>\n",
       "      <td>   6.000000</td>\n",
       "      <td>   0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>  76.000000</td>\n",
       "      <td>   4.000000</td>\n",
       "      <td> 190.000000</td>\n",
       "      <td> 564.000000</td>\n",
       "      <td>   2.000000</td>\n",
       "      <td> 202.000000</td>\n",
       "      <td>   4.200000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   3.000000</td>\n",
       "      <td>   7.000000</td>\n",
       "      <td>   0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              age  chest_pain  rest_blood_press  cholesterol    rest_ecg  \\\n",
       "count  411.000000  411.000000        411.000000   411.000000  411.000000   \n",
       "mean    50.547445    2.761557        130.021042   226.575368    0.547445   \n",
       "std      9.433700    0.903425         16.460208    74.301504    0.805204   \n",
       "min     28.000000    1.000000         80.000000     0.000000    0.000000   \n",
       "25%     43.000000    2.000000        120.000000   199.130337    0.000000   \n",
       "50%     51.000000    3.000000        130.000000   225.000000    0.000000   \n",
       "75%     57.000000    4.000000        140.000000   266.000000    1.000000   \n",
       "max     76.000000    4.000000        190.000000   564.000000    2.000000   \n",
       "\n",
       "       max_heart_rate  ST_depression  Peak_ST_seg  major_vessels        thal  \\\n",
       "count      411.000000     411.000000   411.000000     411.000000  411.000000   \n",
       "mean       148.252830       0.441963     1.729927       0.111922    5.085158   \n",
       "std         23.152969       0.704565     0.515662       0.427276    1.510951   \n",
       "min         69.000000      -1.100000     1.000000       0.000000    3.000000   \n",
       "25%        135.500000       0.000000     1.000000       0.000000    3.000000   \n",
       "50%        150.000000       0.000000     2.000000       0.000000    6.000000   \n",
       "75%        165.000000       0.883178     2.000000       0.000000    6.000000   \n",
       "max        202.000000       4.200000     3.000000       3.000000    7.000000   \n",
       "\n",
       "       has_heart_disease  \n",
       "count                411  \n",
       "mean                   0  \n",
       "std                    0  \n",
       "min                    0  \n",
       "25%                    0  \n",
       "50%                    0  \n",
       "75%                    0  \n",
       "max                    0  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "df_imputed[df_imputed.has_heart_disease==0].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      age        is_male   chest_pain    rest_blood_press  cholesterol   \n",
       " Min.   :28.00   0:144   Min.   :1.000   Min.   : 80      Min.   :  0.0  \n",
       " 1st Qu.:43.00   1:267   1st Qu.:2.000   1st Qu.:120      1st Qu.:199.1  \n",
       " Median :51.00           Median :3.000   Median :130      Median :225.0  \n",
       " Mean   :50.55           Mean   :2.762   Mean   :130      Mean   :226.6  \n",
       " 3rd Qu.:57.00           3rd Qu.:4.000   3rd Qu.:140      3rd Qu.:266.0  \n",
       " Max.   :76.00           Max.   :4.000   Max.   :190      Max.   :564.0  \n",
       "                                                                         \n",
       " high_blood_sugar    rest_ecg      max_heart_rate  exer_angina\n",
       " -999:  0         Min.   :0.0000   Min.   : 69.0   -999:  0   \n",
       " 0   :353         1st Qu.:0.0000   1st Qu.:135.5   0   :336   \n",
       " 1   : 44         Median :0.0000   Median :150.0   1   : 55   \n",
       " NA's: 14         Mean   :0.5474   Mean   :148.3   NA's: 20   \n",
       "                  3rd Qu.:1.0000   3rd Qu.:165.0              \n",
       "                  Max.   :2.0000   Max.   :202.0              \n",
       "                                                              \n",
       " ST_depression      Peak_ST_seg    major_vessels         thal      \n",
       " Min.   :-1.1000   Min.   :1.000   Min.   :0.0000   Min.   :3.000  \n",
       " 1st Qu.: 0.0000   1st Qu.:1.000   1st Qu.:0.0000   1st Qu.:3.000  \n",
       " Median : 0.0000   Median :1.000   Median :0.0000   Median :3.000  \n",
       " Mean   : 0.4417   Mean   :1.491   Mean   :0.2788   Mean   :3.989  \n",
       " 3rd Qu.: 0.8788   3rd Qu.:2.000   3rd Qu.:0.0000   3rd Qu.:6.000  \n",
       " Max.   : 4.2000   Max.   :3.000   Max.   :3.0000   Max.   :7.000  \n",
       "                   NA's   :193     NA's   :246      NA's   :224    \n",
       " has_heart_disease\n",
       " Min.   :0        \n",
       " 1st Qu.:0        \n",
       " Median :0        \n",
       " Mean   :0        \n",
       " 3rd Qu.:0        \n",
       " Max.   :0        \n",
       "                  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "summary(df_imputed[df_imputed$has_heart_disease==0, ])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>has_heart_disease</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td> 51</td>\n",
       "      <td> 3</td>\n",
       "      <td> 130.000000</td>\n",
       "      <td> 225.0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 150.0</td>\n",
       "      <td> 0.00</td>\n",
       "      <td> 2</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td> 55</td>\n",
       "      <td> 4</td>\n",
       "      <td> 130.000000</td>\n",
       "      <td> 226.0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 130.0</td>\n",
       "      <td> 1.00</td>\n",
       "      <td> 2</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td> 58</td>\n",
       "      <td> 4</td>\n",
       "      <td> 132.132404</td>\n",
       "      <td> 193.0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 130.0</td>\n",
       "      <td> 1.40</td>\n",
       "      <td> 2</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td> 60</td>\n",
       "      <td> 4</td>\n",
       "      <td> 132.132404</td>\n",
       "      <td> 212.0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 122.0</td>\n",
       "      <td> 1.00</td>\n",
       "      <td> 2</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td> 59</td>\n",
       "      <td> 4</td>\n",
       "      <td> 133.066202</td>\n",
       "      <td> 218.5</td>\n",
       "      <td> 1</td>\n",
       "      <td> 126.5</td>\n",
       "      <td> 2.45</td>\n",
       "      <td> 2</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   age  chest_pain  rest_blood_press  cholesterol  rest_ecg  \\\n",
       "has_heart_disease                                                             \n",
       "0                   51           3        130.000000        225.0         0   \n",
       "1                   55           4        130.000000        226.0         0   \n",
       "2                   58           4        132.132404        193.0         0   \n",
       "3                   60           4        132.132404        212.0         1   \n",
       "4                   59           4        133.066202        218.5         1   \n",
       "\n",
       "                   max_heart_rate  ST_depression  Peak_ST_seg  major_vessels  \\\n",
       "has_heart_disease                                                              \n",
       "0                           150.0           0.00            2              0   \n",
       "1                           130.0           1.00            2              0   \n",
       "2                           130.0           1.40            2              0   \n",
       "3                           122.0           1.00            2              0   \n",
       "4                           126.5           2.45            2              0   \n",
       "\n",
       "                   thal  \n",
       "has_heart_disease        \n",
       "0                     6  \n",
       "1                     6  \n",
       "2                     6  \n",
       "3                     6  \n",
       "4                     6  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "# or we can use the extremely useful \"groupby\" function\n",
    "df_imputed.groupby(by='has_heart_disease').median()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>has_heart_disease</th><th scope=col>age</th><th scope=col>chest_pain</th><th scope=col>rest_blood_press</th><th scope=col>cholesterol</th><th scope=col>rest_ecg</th><th scope=col>max_heart_rate</th><th scope=col>ST_depression</th><th scope=col>Peak_ST_seg</th><th scope=col>major_vessels</th><th scope=col>thal</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>1</th><td>0</td><td>51</td><td>3</td><td>NA</td><td>NA</td><td>0</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>2</th><td>1</td><td>55</td><td>4</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>3</th><td>2</td><td>58</td><td>4</td><td>NA</td><td>NA</td><td>0</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>4</th><td>3</td><td>60</td><td>4</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "\t<tr><th scope=row>5</th><td>4</td><td>59</td><td>4</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|lllllllllll}\n",
       "  & has_heart_disease & age & chest_pain & rest_blood_press & cholesterol & rest_ecg & max_heart_rate & ST_depression & Peak_ST_seg & major_vessels & thal\\\\\n",
       "\\hline\n",
       "\t1 & 0 & 51 & 3 & NA & NA & 0 & NA & NA & NA & NA & NA\\\\\n",
       "\t2 & 1 & 55 & 4 & NA & NA & NA & NA & NA & NA & NA & NA\\\\\n",
       "\t3 & 2 & 58 & 4 & NA & NA & 0 & NA & NA & NA & NA & NA\\\\\n",
       "\t4 & 3 & 60 & 4 & NA & NA & 1 & NA & NA & NA & NA & NA\\\\\n",
       "\t5 & 4 & 59 & 4 & NA & NA & 1 & NA & NA & NA & NA & NA\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "Source: local data frame [5 x 11]\n",
       "\n",
       "  has_heart_disease   age chest_pain rest_blood_press cholesterol rest_ecg\n",
       "              (dbl) (dbl)      (dbl)            (lgl)       (lgl)    (dbl)\n",
       "1                 0    51          3               NA          NA        0\n",
       "2                 1    55          4               NA          NA       NA\n",
       "3                 2    58          4               NA          NA        0\n",
       "4                 3    60          4               NA          NA        1\n",
       "5                 4    59          4               NA          NA        1\n",
       "Variables not shown: max_heart_rate (lgl), ST_depression (lgl), Peak_ST_seg\n",
       "  (lgl), major_vessels (lgl), thal (lgl)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#R\n",
    "#or we can use the extremely useful \"groupby\" function\n",
    "library(dplyr)\n",
    "numCols <- sapply(df, is.numeric)\n",
    "\n",
    "df[,numCols] %>%\n",
    "  group_by(has_heart_disease) %>%\n",
    "  summarise_each(funs(median))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>has_heart_disease</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>False</th>\n",
       "      <td> 50.547445</td>\n",
       "      <td> 2.761557</td>\n",
       "      <td> 130.021042</td>\n",
       "      <td> 226.575368</td>\n",
       "      <td> 0.547445</td>\n",
       "      <td> 148.252830</td>\n",
       "      <td> 0.441963</td>\n",
       "      <td> 1.729927</td>\n",
       "      <td> 0.111922</td>\n",
       "      <td> 5.085158</td>\n",
       "      <td> 0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>True </th>\n",
       "      <td> 55.903733</td>\n",
       "      <td> 3.644401</td>\n",
       "      <td> 133.837257</td>\n",
       "      <td> 176.969418</td>\n",
       "      <td> 0.648330</td>\n",
       "      <td> 128.899997</td>\n",
       "      <td> 1.239443</td>\n",
       "      <td> 1.943026</td>\n",
       "      <td> 0.320236</td>\n",
       "      <td> 5.960707</td>\n",
       "      <td> 1.799607</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         age  chest_pain  rest_blood_press  cholesterol  \\\n",
       "has_heart_disease                                                         \n",
       "False              50.547445    2.761557        130.021042   226.575368   \n",
       "True               55.903733    3.644401        133.837257   176.969418   \n",
       "\n",
       "                   rest_ecg  max_heart_rate  ST_depression  Peak_ST_seg  \\\n",
       "has_heart_disease                                                         \n",
       "False              0.547445      148.252830       0.441963     1.729927   \n",
       "True               0.648330      128.899997       1.239443     1.943026   \n",
       "\n",
       "                   major_vessels      thal  has_heart_disease  \n",
       "has_heart_disease                                              \n",
       "False                   0.111922  5.085158           0.000000  \n",
       "True                    0.320236  5.960707           1.799607  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "df_imputed.groupby(by=df_imputed.has_heart_disease>0).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>major_vessels</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>False</th>\n",
       "      <td> 53.368889</td>\n",
       "      <td> 3.241111</td>\n",
       "      <td> 132.026458</td>\n",
       "      <td> 197.656567</td>\n",
       "      <td> 0.586667</td>\n",
       "      <td> 137.612235</td>\n",
       "      <td> 0.861359</td>\n",
       "      <td> 1.847778</td>\n",
       "      <td> 0.165556</td>\n",
       "      <td> 5.566667</td>\n",
       "      <td> 0.966667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>True </th>\n",
       "      <td> 59.900000</td>\n",
       "      <td> 3.650000</td>\n",
       "      <td> 136.900000</td>\n",
       "      <td> 265.450000</td>\n",
       "      <td> 1.350000</td>\n",
       "      <td> 134.550000</td>\n",
       "      <td> 1.865000</td>\n",
       "      <td> 1.850000</td>\n",
       "      <td> 3.000000</td>\n",
       "      <td> 5.700000</td>\n",
       "      <td> 2.300000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     age  chest_pain  rest_blood_press  cholesterol  rest_ecg  \\\n",
       "major_vessels                                                                   \n",
       "False          53.368889    3.241111        132.026458   197.656567  0.586667   \n",
       "True           59.900000    3.650000        136.900000   265.450000  1.350000   \n",
       "\n",
       "               max_heart_rate  ST_depression  Peak_ST_seg  major_vessels  \\\n",
       "major_vessels                                                              \n",
       "False              137.612235       0.861359     1.847778       0.165556   \n",
       "True               134.550000       1.865000     1.850000       3.000000   \n",
       "\n",
       "                   thal  has_heart_disease  \n",
       "major_vessels                               \n",
       "False          5.566667           0.966667  \n",
       "True           5.700000           2.300000  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "df_imputed.groupby(by=df_imputed.major_vessels>2).mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### One Hot Encoding of Categorical Variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chest_1</th>\n",
       "      <th>chest_2</th>\n",
       "      <th>chest_3</th>\n",
       "      <th>chest_4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   chest_1  chest_2  chest_3  chest_4\n",
       "0        1        0        0        0\n",
       "1        0        0        0        1\n",
       "2        0        0        0        1\n",
       "3        0        0        1        0\n",
       "4        0        1        0        0"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "# one hot encoded variables can be created using the get_dummies variable\n",
    "tmpdf = pd.get_dummies(df_imputed['chest_pain'],prefix='chest')\n",
    "\n",
    "tmpdf.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>is_male_0</th>\n",
       "      <th>is_male_1</th>\n",
       "      <th>high_blood_sugar_0.0</th>\n",
       "      <th>high_blood_sugar_0</th>\n",
       "      <th>high_blood_sugar_1</th>\n",
       "      <th>exer_angina_0.0</th>\n",
       "      <th>exer_angina_0</th>\n",
       "      <th>exer_angina_1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "      <td> 0</td>\n",
       "      <td> 1</td>\n",
       "      <td> 0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   is_male_0  is_male_1  high_blood_sugar_0.0  high_blood_sugar_0  \\\n",
       "0          0          1                     0                   0   \n",
       "1          0          1                     0                   1   \n",
       "2          0          1                     0                   1   \n",
       "3          0          1                     0                   1   \n",
       "4          1          0                     0                   1   \n",
       "\n",
       "   high_blood_sugar_1  exer_angina_0.0  exer_angina_0  exer_angina_1  \n",
       "0                   1                0              1              0  \n",
       "1                   0                0              0              1  \n",
       "2                   0                0              0              1  \n",
       "3                   0                0              1              0  \n",
       "4                   0                0              1              0  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Pandas\n",
    "#one hot encoding of ALL categorical variables\n",
    "# there is lot going on in this one line of code, so let's step through it\n",
    "\n",
    "# pd.concat([*]], axis=1) // this line of code concatenates all the data frames in the [*] list\n",
    "# [** for col in categ_features] // this steps through each feature in categ_features and \n",
    "#                                //   creates a new element in a list based on the output of **\n",
    "# pd.get_dummies(df_imputed[col],prefix=col) // this creates a one hot encoded dataframe of the variable=col (like code above)\n",
    "\n",
    "one_hot_df = pd.concat([pd.get_dummies(df_imputed[col],prefix=col) for col in categ_features], axis=1)\n",
    "\n",
    "one_hot_df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calling R from iPython\n",
    "\n",
    "- Note: you will need R installed on your machine to run these!!\n",
    "\n",
    "iPython has a lot of interesting \"magics\" built in. If you use R and have it installed on your machine, then you can write and look at R code directly from iPython cells. R also uses data frames, which we can push data into directly from the Pandas object we are using:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Library/Python/2.7/site-packages/IPython/extensions/rmagic.py:693: UserWarning: The rmagic extension in IPython is deprecated in favour of rpy2.ipython. If available, that will be loaded instead.\n",
      "http://rpy.sourceforge.net/\n",
      "  warnings.warn(\"The rmagic extension in IPython is deprecated in favour of \"\n"
     ]
    }
   ],
   "source": [
    "# CONVERT PANDAS DATAFRAME TO R DATA.FRAME\n",
    "# adapted from: http://tagteam.harvard.edu/hub_feeds/1981/feed_items/196017\n",
    "# I have better luck with both calls here\n",
    "\n",
    "%load_ext rmagic\n",
    "%load_ext rpy2.ipython\n",
    "\n",
    "df_colnames = df_imputed.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index([u'age', u'is_male', u'chest_pain', u'rest_blood_press', u'cholesterol', u'high_blood_sugar', u'rest_ecg', u'max_heart_rate', u'exer_angina', u'ST_depression', u'Peak_ST_seg', u'major_vessels', u'thal', u'has_heart_disease'], dtype='object')"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_colnames"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now lets take the data frame from pandas and tell Rmagics that we want to have variables available in the R workspace. We use the %%R command to tell iPython that the entire cell is R code. The \"-i\" tells Rmagics that we want to transfer those variables over to R.\n",
    "\n",
    "The following code will take the variables df_imputed and df_colnames into the R workspace and test if they are truly saved as R data.frames type variables."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1] TRUE\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%R -i df_imputed,df_colnames \n",
    "\n",
    "colnames(df_imputed) <- unlist(df_colnames); \n",
    "print(is.data.frame(df_imputed))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "They were data.frames! Great. Let's call an R function on the data.frame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      age        is_male   chest_pain   rest_blood_press  cholesterol   \n",
       " Min.   :28.00   0:194   Min.   :1.00   Min.   :  0.0    Min.   :  0.0  \n",
       " 1st Qu.:47.00   1:726   1st Qu.:3.00   1st Qu.:120.0    1st Qu.:177.8  \n",
       " Median :54.00           Median :4.00   Median :130.0    Median :221.0  \n",
       " Mean   :53.51           Mean   :3.25   Mean   :132.1    Mean   :199.1  \n",
       " 3rd Qu.:60.00           3rd Qu.:4.00   3rd Qu.:140.0    3rd Qu.:267.0  \n",
       " Max.   :77.00           Max.   :4.00   Max.   :200.0    Max.   :603.0  \n",
       " high_blood_sugar    rest_ecg      max_heart_rate  exer_angina\n",
       " 0  :692          Min.   :0.0000   Min.   : 60.0   0  :528    \n",
       " 0.0: 90          1st Qu.:0.0000   1st Qu.:120.0   0.0: 55    \n",
       " 1  :138          Median :0.0000   Median :138.0   1  :337    \n",
       "                  Mean   :0.6033   Mean   :137.5              \n",
       "                  3rd Qu.:1.0000   3rd Qu.:156.0              \n",
       "                  Max.   :2.0000   Max.   :202.0              \n",
       " ST_depression      Peak_ST_seg    major_vessels         thal     \n",
       " Min.   :-2.6000   Min.   :1.000   Min.   :0.0000   Min.   :3.00  \n",
       " 1st Qu.: 0.0000   1st Qu.:2.000   1st Qu.:0.0000   1st Qu.:6.00  \n",
       " Median : 0.8000   Median :2.000   Median :0.0000   Median :6.00  \n",
       " Mean   : 0.8832   Mean   :1.848   Mean   :0.2272   Mean   :5.57  \n",
       " 3rd Qu.: 1.5000   3rd Qu.:2.000   3rd Qu.:0.0000   3rd Qu.:6.00  \n",
       " Max.   : 6.2000   Max.   :3.000   Max.   :3.0000   Max.   :7.00  \n",
       " has_heart_disease\n",
       " Min.   :0.0000   \n",
       " 1st Qu.:0.0000   \n",
       " Median :1.0000   \n",
       " Mean   :0.9957   \n",
       " 3rd Qu.:2.0000   \n",
       " Max.   :4.0000   \n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%R -i df_imputed \n",
    "print(summary(df_imputed))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So we are able to call some R and get console output, now let's make some changes to the data.fram in R and print the result back in python."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "original: 0    63\n",
      "1    67\n",
      "2    67\n",
      "3    37\n",
      "4    41\n",
      "Name: age, dtype: int64\n",
      "after manipulation in R: 0    63\n",
      "1    67\n",
      "2    67\n",
      "3    37\n",
      "4    41\n",
      "Name: age, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print 'original:', df_imputed.age.head()\n",
    "\n",
    "# give df_imputed, then multiply it by to in R\n",
    "# the %R command tells iPython its just one line of R code\n",
    "%R -i df_imputed df_imputed$age <- df_imputed$age*2\n",
    "\n",
    "# now we are back in python, did it change?\n",
    "print 'after manipulation in R:', df_imputed.age.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Well, it looks like the data was not synchronized... So instead let's setup an output variable for the DataFrame that we send into R. `-i df_imputed` means that we are sending in the DataFrame as an R data.frame. `-o df_imputed` means we are also getting the same variable and copying it back to the python workspace."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "original: 0    63\n",
      "1    67\n",
      "2    67\n",
      "3    37\n",
      "4    41\n",
      "Name: age, dtype: int64\n",
      "after manipulation in R: 0    126\n",
      "1    134\n",
      "2    134\n",
      "3     74\n",
      "4     82\n",
      "Name: age, dtype: float64\n"
     ]
    }
   ],
   "source": [
    "print 'original:', df_imputed.age.head() \n",
    "\n",
    "# This is the same code as before, but now with an output variable\n",
    "%R -i df_imputed -o df_imputed  df_imputed$age <- df_imputed$age*2\n",
    "# you can place the above on any line to make sure that the data stays\n",
    "# synchronized between pandas and python\n",
    "print 'after manipulation in R:', df_imputed.age.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Awesome. So now we can send DataFrames into R, manipulate them, and get them back into the python workspace. Is this memory hogging? Yes. Is it really useful for when you want to connect and work with different parts of R? You betcha."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null float64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int32\n",
      "rest_blood_press     920 non-null float64\n",
      "cholesterol          920 non-null float64\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null float64\n",
      "max_heart_rate       920 non-null float64\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null float64\n",
      "Peak_ST_seg          920 non-null float64\n",
      "major_vessels        920 non-null float64\n",
      "thal                 920 non-null float64\n",
      "has_heart_disease    920 non-null int32\n",
      "dtypes: float64(9), int32(2), object(3)"
     ]
    }
   ],
   "source": [
    "# We can also just go and get new variables from R and \n",
    "# have them spit them back out for us\n",
    "# here I am sending in df_imputed and getting back a data frame\n",
    "# created in R\n",
    "%R -i df_imputed -o df_from_R df_from_R <- df_imputed\n",
    "\n",
    "# notice that the only differebce is that the integers are 32 bits\n",
    "df_from_R.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "That's it. Use this as a reference sheet for Pandas, some basic imputation, and calling R code. Thanks!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:MLEnv]",
   "language": "python",
   "name": "conda-env-MLEnv-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
